From 4ab4ac9dc1e85c8e61dce47f84429e088fa7f247 Mon Sep 17 00:00:00 2001 From: John Goerzen Date: Thu, 14 Feb 2008 10:46:39 -0600 Subject: [PATCH] Import upstream gpsbabel version 1.3.4 Imported gpsbabel_1.3.4.orig.tar.gz into Mercurial repository --- .cvsignore | 4 + AUTHORS | 3 + Makefile.in | 130 +- README.contrib | 22 + alan.c | 10 +- an1.c | 5 +- axim_gpb.c | 4 +- bcr.c | 198 +- brauniger_iq.c | 2 +- cet.c | 17 +- cet.h | 6 +- cet/ansi_x3_4_1968.h | 580 +- cet/cp1250.h | 75 +- cet/cp1251.h | 46 +- cet/cp1252.h | 66 +- cet/cp1253.h | 35 +- cet/cp1254.h | 77 +- cet/cp1255.h | 44 +- cet/cp1256.h | 34 +- cet/cp1257.h | 19 +- cet_util.c | 100 +- cetus.c | 77 +- coldsync/Artistic | 131 - coldsync/Makefile | 0 coldsync/Makefile.in | 0 coldsync/README | 211 - coldsync/README.gpsbabel | 10 - coldsync/cs-config.h | 8 - coldsync/palm.h | 55 - coldsync/pconn/util.h | 60 - coldsync/pdb.c | 2038 -- coldsync/pdb.h | 273 - coldsync/util.c | 293 - compegps.c | 17 +- configure | 4908 +++-- configure.in | 8 +- copilot.c | 83 +- coto.c | 124 +- csv_util.c | 163 +- defs.h | 107 +- delgpl.c | 8 +- dmtlog.c | 13 +- g7towin.c | 546 + garmin.c | 91 + garmin_fs.c | 174 +- garmin_fs.h | 27 +- garmin_gpi.c | 1207 ++ garmin_gpi.h | 112 + garmin_tables.c | 123 +- garmin_tables.h | 5 + garmin_txt.c | 212 +- gbfile.c | 17 +- gbser.c | 4 +- gbser_posix.c | 18 +- gbversion.h | 2 +- gcdb.c | 66 +- gdb.c | 2768 ++- geo.c | 2 +- geoniche.c | 124 +- ggv_log.c | 276 + globals.c | 1 + google.c | 237 +- gpilots.c | 71 +- gpsbabel.html | 560 +- gpspilot.c | 64 +- gpssim.c | 6 +- gpsutil.c | 2 +- gpx.c | 147 +- html.c | 98 +- igc.c | 9 +- inifile.c | 16 +- internal_styles.c | 58 +- jeeps/gps.h | 21 +- jeeps/gpsapp.c | 644 +- jeeps/gpsapp.h | 41 +- jeeps/gpscom.c | 53 + jeeps/gpscom.h | 6 + jeeps/gpslibusb.c | 20 +- jeeps/gpsmath.c | 111 +- jeeps/gpsmath.h | 6 + jeeps/gpsmem.c | 39 + jeeps/gpsmem.h | 2 + jeeps/gpsprot.c | 17 +- jeeps/gpsprot.h | 117 +- kml.c | 50 +- lowranceusr.c | 55 +- mag_pdb.c | 34 +- maggeo.c | 2 +- magnav.c | 67 +- magproto.c | 24 +- main.c | 49 +- mapopolis.c | 72 +- mapsend.c | 2 + mapsource.c | 16 +- mkshort.c | 12 +- msroute.c | 128 +- msvc/GPSBabel-msvc7.vcproj | 98 +- msvc/GPSBabel.dsp | 58 +- msvc/GPSBabel.vcproj | 146 +- msvc/build.bat | 7 +- navicache.c | 15 +- nmea.c | 182 +- ozi.c | 59 +- palmdoc.c | 71 +- pathaway.c | 126 +- pcx.c | 4 +- pdbfile.c | 431 + pdbfile.h | 84 + quovadis.c | 83 +- quovadis.h | 3 +- raymarine.c | 387 +- reference/cet/cet-sample.latin1.txt | 10 +- reference/earth-expertgps.kml | 158 +- reference/earth-gc.kml | 6 - reference/expertgps-g7t.txt | 216 + reference/expertgps.g7t | 1145 ++ reference/expertgps.rwf | 4499 +++-- reference/garmin_gpi.gpi | Bin 0 -> 7776 bytes reference/garmin_gpi.gpx | 526 + reference/garmin_gpi2.gpx | 526 + reference/garmin_txt-uni.csv | 15 + reference/gpi_ext-sample.csv | 10 + reference/gpi_ext-sample.gpi | Bin 0 -> 1507 bytes reference/multiple-links.gpx | 35 + reference/route/bcr-sample.bcr | 6 +- reference/route/bcr-sample.gpx | 120 +- reference/route/bcr-sample2.bcr | 27 +- reference/route/tef_xml.sample.gpx | 1586 +- reference/route/tomtom_itn.itn | 46 + reference/tomtom_poi.asc | 90 + reference/track/ggv_log-sample.log | Bin 0 -> 31397 bytes reference/track/pcx.trk | 3 + reference/track/stmwpp-route.gpx | 64 + reference/track/tracks.gpssim | 128 +- reference/track/vitovtt-sample.gpx | 7478 +++++++ reference/track/vitovtt-sample.vtt | Bin 0 -> 59720 bytes reference/transform-rte.gpx | 8 +- reference/transform-wpt.gpx | 8 +- reference/wbt-200.gpx | 521 +- reference/wbt-201.gpx | 16151 ++++++++++++++++ reference/wbt-201.tk1 | Bin 0 -> 65512 bytes route.c | 6 +- smplrout.c | 9 +- stmsdf.c | 48 +- stmwpp.c | 67 +- style/tomtom_asc.style | 27 + style/tomtom_itn.style | 23 + tef_xml.c | 284 +- test-all | 6 +- testo | 73 +- text.c | 37 +- tools/mkmoreclean | 2 +- trackfilter.c | 28 +- unicsv.c | 1192 +- util.c | 167 +- vecs.c | 44 +- vitosmt.c | 19 +- vitovtt.c | 139 + waypt.c | 116 +- wbt-200.c | 610 +- win32/GPSBabelGUI.exe | Bin 1002504 -> 1038088 bytes win32/gpsbabel.rc.in | 2 +- win32/gui-2/GPSBabelGUI.dof | 6 +- win32/gui-2/GPSBabelGUI.res | Bin 1748 -> 1748 bytes win32/gui-2/Makefile | 6 +- win32/gui-2/about.dfm | Bin 3505 -> 3505 bytes win32/gui-2/about.pas | 1 + win32/gui-2/common.pas | 25 +- win32/gui-2/default.po | 402 +- win32/gui-2/gpsbabel.po | 14 +- win32/gui-2/ignore.po | 84 +- win32/gui-2/locale/de/LC_MESSAGES/default.po | 183 +- win32/gui-2/locale/de/LC_MESSAGES/gpsbabel.po | 20 +- win32/gui-2/locale/es/LC_MESSAGES/default.po | 183 +- win32/gui-2/locale/es/LC_MESSAGES/gpsbabel.po | 804 +- win32/gui-2/locale/fr/LC_MESSAGES/default.po | 184 +- win32/gui-2/locale/fr/LC_MESSAGES/gpsbabel.po | 20 +- win32/gui-2/locale/hu/LC_MESSAGES/default.po | 930 + win32/gui-2/locale/hu/LC_MESSAGES/delphi.po | 2258 +++ win32/gui-2/locale/hu/LC_MESSAGES/gpsbabel.po | 407 + win32/gui-2/main.dfm | Bin 37152 -> 37208 bytes win32/gui-2/main.pas | 5 +- win32/gui-2/options.pas | 44 +- win32/gui-2/select.pas | 5 +- xcsv.c | 58 +- xhtmlent.c | 515 + xmldoc/chapters/_chapters.xml | 1 + xmldoc/chapters/allchapters.xml | 1 + xmldoc/chapters/build.xml | 2 +- xmldoc/chapters/glossary.xml | 75 + xmldoc/chapters/preface.xml | 4 +- xmldoc/chapters/styles.xml | 99 +- xmldoc/chapters/use.xml | 21 +- xmldoc/formats/g7towin.xml | 9 + xmldoc/formats/garmin.xml | 74 +- xmldoc/formats/garmin_gpi.xml | 32 + xmldoc/formats/ggv_log.xml | 12 + xmldoc/formats/lowranceusr.xml | 6 +- xmldoc/formats/options/an1-nourl.xml | 12 + xmldoc/formats/options/garmin_gpi-bitmap.xml | 13 + .../formats/options/garmin_gpi-category.xml | 9 + xmldoc/formats/options/garmin_gpi-descr.xml | 10 + xmldoc/formats/options/garmin_gpi-hide.xml | 10 + xmldoc/formats/options/garmin_gpi-notes.xml | 11 + .../formats/options/garmin_gpi-position.xml | 9 + xmldoc/formats/options/garmin_txt-grid.xml | 10 +- xmldoc/formats/options/gdb-roadbook.xml | 19 + xmldoc/formats/options/gdb-ver.xml | 4 +- xmldoc/formats/options/lowranceusr-break.xml | 2 +- .../options/lowranceusr-ignoreicons.xml | 3 +- xmldoc/formats/options/lowranceusr-merge.xml | 2 +- .../options/lowranceusr-writeasicons.xml | 3 + .../options/nmea-append_positioning.xml | 5 + xmldoc/formats/options/ozi-pack.xml | 10 + xmldoc/formats/options/raymarine-location.xml | 7 + xmldoc/formats/options/text-splitoutput.xml | 15 + xmldoc/formats/options/unicsv-datum.xml | 4 + xmldoc/formats/options/unicsv-grid.xml | 8 + xmldoc/formats/tomtom_asc.xml | 5 + xmldoc/formats/tomtom_itn.xml | 3 + xmldoc/formats/unicsv.xml | 125 +- xmldoc/formats/vitovtt.xml | 117 + xmldoc/formats/wbt-tk1.xml | 11 + xmldoc/formats/wbt.xml | 2 +- xmldoc/gpsbabel_man.xml | 19 +- xmlgeneric.c | 24 +- xmlgeneric.h | 2 + 227 files changed, 49692 insertions(+), 14002 deletions(-) delete mode 100644 coldsync/Artistic delete mode 100644 coldsync/Makefile delete mode 100644 coldsync/Makefile.in delete mode 100644 coldsync/README delete mode 100644 coldsync/README.gpsbabel delete mode 100644 coldsync/cs-config.h delete mode 100644 coldsync/palm.h delete mode 100644 coldsync/pconn/util.h delete mode 100644 coldsync/pdb.c delete mode 100644 coldsync/pdb.h delete mode 100644 coldsync/util.c create mode 100644 g7towin.c create mode 100644 garmin_gpi.c create mode 100644 garmin_gpi.h create mode 100644 ggv_log.c create mode 100644 pdbfile.c create mode 100644 pdbfile.h create mode 100644 reference/expertgps-g7t.txt create mode 100644 reference/expertgps.g7t create mode 100644 reference/garmin_gpi.gpi create mode 100644 reference/garmin_gpi.gpx create mode 100644 reference/garmin_gpi2.gpx create mode 100644 reference/garmin_txt-uni.csv create mode 100644 reference/gpi_ext-sample.csv create mode 100644 reference/gpi_ext-sample.gpi create mode 100644 reference/multiple-links.gpx create mode 100644 reference/route/tomtom_itn.itn create mode 100644 reference/tomtom_poi.asc create mode 100644 reference/track/ggv_log-sample.log create mode 100644 reference/track/stmwpp-route.gpx create mode 100644 reference/track/vitovtt-sample.gpx create mode 100644 reference/track/vitovtt-sample.vtt create mode 100644 reference/wbt-201.gpx create mode 100644 reference/wbt-201.tk1 create mode 100644 style/tomtom_asc.style create mode 100644 style/tomtom_itn.style create mode 100644 vitovtt.c create mode 100644 win32/gui-2/locale/hu/LC_MESSAGES/default.po create mode 100644 win32/gui-2/locale/hu/LC_MESSAGES/delphi.po create mode 100644 win32/gui-2/locale/hu/LC_MESSAGES/gpsbabel.po create mode 100644 xhtmlent.c create mode 100644 xmldoc/chapters/glossary.xml create mode 100644 xmldoc/formats/g7towin.xml create mode 100644 xmldoc/formats/garmin_gpi.xml create mode 100644 xmldoc/formats/ggv_log.xml create mode 100644 xmldoc/formats/options/an1-nourl.xml create mode 100644 xmldoc/formats/options/garmin_gpi-bitmap.xml create mode 100644 xmldoc/formats/options/garmin_gpi-category.xml create mode 100644 xmldoc/formats/options/garmin_gpi-descr.xml create mode 100644 xmldoc/formats/options/garmin_gpi-hide.xml create mode 100644 xmldoc/formats/options/garmin_gpi-notes.xml create mode 100644 xmldoc/formats/options/garmin_gpi-position.xml create mode 100644 xmldoc/formats/options/gdb-roadbook.xml create mode 100644 xmldoc/formats/options/lowranceusr-writeasicons.xml create mode 100644 xmldoc/formats/options/nmea-append_positioning.xml create mode 100644 xmldoc/formats/options/ozi-pack.xml create mode 100644 xmldoc/formats/options/raymarine-location.xml create mode 100644 xmldoc/formats/options/text-splitoutput.xml create mode 100644 xmldoc/formats/options/unicsv-datum.xml create mode 100644 xmldoc/formats/options/unicsv-grid.xml create mode 100644 xmldoc/formats/tomtom_asc.xml create mode 100644 xmldoc/formats/tomtom_itn.xml create mode 100644 xmldoc/formats/vitovtt.xml create mode 100644 xmldoc/formats/wbt-tk1.xml diff --git a/.cvsignore b/.cvsignore index cb60d98a9..45d939897 100644 --- a/.cvsignore +++ b/.cvsignore @@ -2,6 +2,7 @@ cscope.out cscope.files gpsbabel +gpsbabel-debug gpsbabel.exe gpsbabel.fo gpsbabel.html @@ -16,3 +17,6 @@ config.log config.status CHANGELOG + +coldsync +pilot-link diff --git a/AUTHORS b/AUTHORS index c28c51c21..3e09d772a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -35,9 +35,11 @@ Other contributors and helpers: * Jason Rust * Jeff Kalikstein * Jeremy Atherton +* Jeremy Ehrhardt * Jim Bensman * Jochen Becker * John Temples +* Jon McClintock * Josh McKee * Justin Broughton * Kjeld Jensen @@ -54,6 +56,7 @@ Other contributors and helpers: * Rick Richardson * Robert Shaw * Scott Brynen +* Sprok Bence * Steve Chamberlin * Sven Dovideit * Tim Zickus diff --git a/Makefile.in b/Makefile.in index 19284ecec..4366b462e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -33,7 +33,7 @@ OUTPUT_SWITCH=-o # #OPTIMIZATION=-O $(EXTRA_OPTIMIZATION) #DEBUGGING=-g $(EXTRA_DEBUGGING) # add -DDEBUG_MEM to turn on memory allocation logging -GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) -I. -I@srcdir@/coldsync \ +GBCFLAGS=$(EXTRA_CFLAGS) $(DEBUGGING) -I. \ $(OPTIMIZATION) @CFLAGS@ LDFLAGS=$(EXTRA_LDFLAGS) @LDFLAGS@ PREFIX=@prefix@ @@ -54,7 +54,8 @@ FMTS=magproto.o gpx.o geo.o mapsend.o mapsource.o garmin_tables.o \ tef_xml.o maggeo.o pathaway.o vitosmt.o gdb.o bcr.o coto.o \ ignrando.o stmwpp.o msroute.o cst.o nmn4.o mag_pdb.o compegps.o \ yahoo.o unicsv.o wfff_xml.o garmin_txt.o axim_gpb.o gpssim.o \ - wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o + wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \ + ggv_log.o g7towin.o garmin_gpi.o FILTERS=position.o radius.o duplicate.o arcdist.o polygon.o smplrout.o \ reverse_route.o sort.o stackfilter.o trackfilter.o discard.o \ @@ -72,7 +73,7 @@ JEEPS=jeeps/gpsapp.o jeeps/gpscom.o \ # jeeps/gpsfmt.o jeeps/gpsinput.o jeeps/gpsproj.o -COLDSYNC=coldsync/util.o coldsync/pdb.o +@PALM_DB_CMT@PALM_DB=pdbfile.o SHAPE=shapelib/shpopen.o shapelib/dbfopen.o @@ -83,9 +84,9 @@ ZLIB=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o \ LIBOBJS = queue.o route.o waypt.o filter_vecs.o util.o vecs.o mkshort.o \ csv_util.o strptime.o grtcirc.o vmem.o util_crc.o xmlgeneric.o \ uuid.o formspec.o xmltag.o cet.o cet_util.o fatal.o rgbcolors.o \ - inifile.o garmin_fs.o gbsleep.o units.o @GBSER@ gbser.o \ + xhtmlent.o inifile.o garmin_fs.o gbsleep.o units.o @GBSER@ gbser.o \ gbfile.o \ - $(COLDSYNC) $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS) + $(PALM_DB) $(GARMIN) $(JEEPS) $(SHAPE) @ZLIB@ $(FMTS) $(FILTERS) OBJS = main.o globals.o $(LIBOBJS) @FILEINFO@ .c.o: @@ -152,7 +153,7 @@ torture: # # This will only work on UNIX-like substances. # -install: @INSTALL_DEBUG@ +install: @INSTALL_DEBUG@ gpsbabel$(EXEEXT) @mkdir -p $(INSTALL_DIR)/bin install gpsbabel $(INSTALL_DIR)/bin/ @@ -229,7 +230,7 @@ FORCE: # file list for windows package WINFILES = gpsbabel.exe mingw/libexpat.dll win32/GPSBabelGUI.exe win32/gui-2/README.gui \ - README* AUTHORS COPYING gpsbabel.html + README.contrib AUTHORS COPYING gpsbabel.html # # Do administrative-y things to the tree. Verify that everything is checked @@ -285,6 +286,9 @@ release-rpm: # binutils, runtime, w32api, and gcc-core seem to be required. # +cross-configure: + CC=i386-mingw32-gcc LDFLAGS="-s" @srcdir@/configure --host=i386-pc-mingw32 --with-cet=all --with-expathdr=@srcdir@/mingw/include --with-libexpat=@srcdir@/mingw/lib + release-winbuild: rm -fr /tmp/gpsbabel-$(VERSIOND)-cross cp -a gpsbabel-$(VERSIOND) /tmp/gpsbabel-$(VERSIOND)-cross @@ -327,17 +331,16 @@ arcdist.o: arcdist.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ axim_gpb.o: axim_gpb.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h bcr.o: bcr.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h garmin_tables.h + gbfile.h cet.h cet_util.h inifile.h csv_util.h garmin_tables.h brauniger_iq.o: brauniger_iq.c defs.h config.h queue.h gbtypes.h \ zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h gbser.h cet.o: cet.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h cetus.o: cetus.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h pdbfile.h cet_util.o: cet_util.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h cet/iso_8859_1.h \ - cet/iso_8859_15.h cet/ansi_x3_4_1968.h cet/cp1252.h cet/iso_8859_2.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h cet/ansi_x3_4_1968.h \ + cet/iso_8859_1.h cet/iso_8859_15.h cet/cp1252.h cet/iso_8859_2.h \ cet/cp1250.h cet/latin_greek_1.h cet/macintosh.h cet/cp1251.h \ cet/cp1253.h cet/cp1254.h cet/cp1255.h cet/cp1256.h cet/cp1257.h \ cet/ibm437.h cet/ibm850.h cet/ibm851.h cet/ibm852.h cet/ibm855.h \ @@ -356,11 +359,9 @@ compegps.o: compegps.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ jeeps/gpsproj.h copilot.o: copilot.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h grtcirc.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h pdbfile.h coto.o: coto.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h csv_util.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h grtcirc.h + gbfile.h cet.h cet_util.h inifile.h csv_util.h grtcirc.h pdbfile.h cst.o: cst.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h strptime.h csv_util.o: csv_util.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -369,7 +370,7 @@ csv_util.o: csv_util.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h + jeeps/gpsproj.h xmlgeneric.h delgpl.o: delgpl.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h discard.o: discard.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -392,6 +393,13 @@ filter_vecs.o: filter_vecs.c defs.h config.h queue.h gbtypes.h \ filterdefs.h formspec.o: formspec.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h +g7towin.o: g7towin.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h garmin_fs.h \ + jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ + jeeps/gps.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ + jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ + jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ + jeeps/gpsproj.h garmin_tables.h jeeps/gpsmath.h strptime.h garmin.o: garmin.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h jeeps/gps.h \ jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gps.h \ @@ -406,8 +414,20 @@ garmin_fs.o: garmin_fs.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ jeeps/gpsproj.h garmin_tables.h +garmin_gpi.o: garmin_gpi.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h jeeps/gpsmath.h \ + jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ + jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \ + jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \ + jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h \ + garmin_fs.h jeeps/gps.h garmin_gpi.h garmin_tables.o: garmin_tables.c garmin_tables.h defs.h config.h queue.h \ - gbtypes.h zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h + gbtypes.h zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h \ + jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ + jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ + jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ + jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ + jeeps/gpsproj.h garmin_txt.o: garmin_txt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h garmin_fs.h \ jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ @@ -425,24 +445,30 @@ gbser_posix.o: gbser_posix.c defs.h config.h queue.h gbtypes.h \ gbser_private.h gbsleep.o: gbsleep.c config.h gcdb.o: gcdb.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h + gbfile.h cet.h cet_util.h inifile.h pdbfile.h gdb.o: gdb.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h garmin_tables.h jeeps/gpsmath.h \ - jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ + gbfile.h cet.h cet_util.h inifile.h csv_util.h garmin_fs.h jeeps/gps.h \ + jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gps.h \ jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \ jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \ jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h \ - garmin_fs.h jeeps/gps.h + garmin_tables.h grtcirc.h jeeps/gpsmath.h geo.o: geo.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h xmlgeneric.h geoniche.o: geoniche.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h jeeps/gpsmath.h jeeps/gps.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h pdbfile.h \ + jeeps/gpsmath.h jeeps/gps.h \ jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h \ jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \ jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h \ jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h garmin_tables.h +ggv_log.o: ggv_log.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h \ + jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ + jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ + jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ + jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ + jeeps/gpsproj.h globals.o: globals.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h gbversion.h glogbook.o: glogbook.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -450,11 +476,10 @@ glogbook.o: glogbook.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ google.o: google.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h xmlgeneric.h gpilots.o: gpilots.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h garmin_tables.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h garmin_tables.h \ + pdbfile.h gpspilot.o: gpspilot.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h pdbfile.h gpssim.o: gpssim.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h gpsutil.o: gpsutil.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -507,11 +532,10 @@ maggeo.o: maggeo.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h xmlgeneric.h \ magellan.h magnav.o: magnav.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h pdbfile.h mag_pdb.o: mag_pdb.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h jeeps/gpsmath.h jeeps/gps.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h pdbfile.h \ + jeeps/gpsmath.h jeeps/gps.h \ jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h \ jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \ jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h \ @@ -542,7 +566,11 @@ navicache.o: navicache.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ netstumbler.o: netstumbler.c defs.h config.h queue.h gbtypes.h \ zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h nmea.o: nmea.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h gbser.h strptime.h + gbfile.h cet.h cet_util.h inifile.h gbser.h strptime.h jeeps/gpsmath.h \ + jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ + jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \ + jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \ + jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h nmn4.o: nmn4.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h csv_util.h nukedata.o: nukedata.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -557,12 +585,13 @@ palmdoc.o: palmdoc.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \ jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \ jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h \ - coldsync/palm.h coldsync/../gbtypes.h coldsync/pdb.h + pdbfile.h pathaway.o: pathaway.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h coldsync/palm.h \ - coldsync/../gbtypes.h coldsync/pdb.h csv_util.h strptime.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h strptime.h \ + pdbfile.h pcx.o: pcx.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h garmin_tables.h csv_util.h +pdbfile.o: pdbfile.h pdbfile.c defs.h queue.h gbfile.h polygon.o: polygon.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h filterdefs.h position.o: position.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -574,7 +603,7 @@ psp.o: psp.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ queue.o: queue.c queue.h quovadis.o: quovadis.c quovadis.h defs.h config.h queue.h gbtypes.h \ zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h \ - coldsync/palm.h coldsync/../gbtypes.h coldsync/pdb.h + pdbfile.h radius.o: radius.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h filterdefs.h grtcirc.h raymarine.o: raymarine.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -639,17 +668,21 @@ trackfilter.o: trackfilter.c defs.h config.h queue.h gbtypes.h \ transform.o: transform.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h filterdefs.h unicsv.o: unicsv.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h \ - jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ - jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h garmin_fs.h \ + jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \ + jeeps/gps.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h + jeeps/gpsproj.h garmin_tables.h jeeps/gpsmath.h strptime.h units.o: units.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h util_crc.o: util_crc.c util.o: util.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h + gbfile.h cet.h cet_util.h inifile.h jeeps/gpsmath.h jeeps/gps.h \ + jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h \ + jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \ + jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h \ + jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h uuid.o: uuid.c uuid.h vcf.o: vcf.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h jeeps/gpsmath.h jeeps/gps.h \ @@ -661,10 +694,12 @@ vecs.o: vecs.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h csv_util.h vitosmt.o: vitosmt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h +vitovtt.o: vitovtt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h vmem.o: vmem.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h waypt.o: waypt.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ - zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h + zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h grtcirc.h wbt-200.o: wbt-200.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h gbser.h grtcirc.h wfff_xml.o: wfff_xml.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ @@ -675,16 +710,13 @@ xcsv.o: xcsv.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \ jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \ jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \ jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h +xhtmlent.o: xhtmlent.c xmlgeneric.o: xmlgeneric.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h xmlgeneric.h xmltag.o: xmltag.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h yahoo.o: yahoo.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h xmlgeneric.h -coldsync/pdb.o: coldsync/pdb.c config.h coldsync/cs-config.h \ - coldsync/palm.h coldsync/../gbtypes.h coldsync/pdb.h -coldsync/util.o: coldsync/util.c config.h coldsync/cs-config.h \ - coldsync/pconn/util.h coldsync/palm.h coldsync/../gbtypes.h jeeps/gpsapp.o: jeeps/gpsapp.c jeeps/gps.h jeeps/../defs.h \ jeeps/../config.h jeeps/../queue.h jeeps/../gbtypes.h \ jeeps/../zlib/zlib.h jeeps/../zlib/zconf.h jeeps/../gbfile.h \ @@ -843,5 +875,5 @@ zlib/trees.o: zlib/trees.c zlib/deflate.h zlib/zutil.h zlib/zlib.h \ zlib/zconf.h zlib/trees.h zlib/uncompr.o: zlib/uncompr.c zlib/zlib.h zlib/zconf.h zlib/zutil.o: zlib/zutil.c zlib/zutil.h zlib/zlib.h zlib/zconf.h -internal_styles.c: mkstyle.sh style/arc.style style/cambridge.style style/csv.style style/cup.style style/custom.style style/dna.style style/fugawi.style style/garmin301.style style/garmin_poi.style style/geonet.style style/gpsdrive.style style/gpsdrivetrack.style style/gpsman.style style/kompass_tk.style style/kompass_wp.style style/ktf2.style style/kwf2.style style/mapconverter.style style/mxf.style style/nima.style style/openoffice.style style/s_and_t.style style/saplus.style style/sportsim.style style/tabsep.style style/xmap2006.style style/xmap.style style/xmapwpt.style +internal_styles.c: mkstyle.sh style/arc.style style/cambridge.style style/csv.style style/cup.style style/custom.style style/dna.style style/fugawi.style style/garmin301.style style/garmin_poi.style style/geonet.style style/gpsdrive.style style/gpsdrivetrack.style style/gpsman.style style/kompass_tk.style style/kompass_wp.style style/ktf2.style style/kwf2.style style/mapconverter.style style/mxf.style style/nima.style style/openoffice.style style/s_and_t.style style/saplus.style style/sportsim.style style/tabsep.style style/tomtom_asc.style style/tomtom_itn.style style/xmap2006.style style/xmap.style style/xmapwpt.style ./mkstyle.sh > internal_styles.c || (rm -f internal_styles.c ; exit 1) diff --git a/README.contrib b/README.contrib index b2f618286..6e447a29d 100644 --- a/README.contrib +++ b/README.contrib @@ -21,6 +21,28 @@ The entire world doesn't run . I've tested this code on at least five different OSes. If you find yourself wanting to insert compiler or OS specific magic, please resist. +Coding consistency is encouraged. The reality is we have a lot of code +that was written by different authors. Some code from other projects is +included. We don't have immutable rules about code style (indention, +curly location, whitespace rules, etc.) but we do ask that you try to +match what is around any code you modify. "When in Rome..." + +If writing new code, we'd prefer a style like: + + int + mumble(int whatever) + { + if (whatevever) { + return blah; + } + } + +...but if you're submitting a new source file that you intend to +maintain and are convinced that two space indents will make the world a +better place, knock yourself out. But if you need to add a line of code +to the above before "return blah" and do it with spaces instead of hard +tabs, that would be bad. + Submitting Patches ------------------ diff --git a/alan.c b/alan.c index fbc1f7251..f7ea61850 100644 --- a/alan.c +++ b/alan.c @@ -586,9 +586,9 @@ static void trl_read(void) { WP->longitude = pt2deg(trklog->pt[j].x); WP->altitude = hgt2m(trklog->sh[j].height); if ( trklog->sh[j].speed >= 0 ) - WP->speed = sp2mps(trklog->sh[j].speed); + WAYPT_SET(WP, speed, sp2mps(trklog->sh[j].speed)) else /* bad speed < 0 - set to 0.0 */ - WP->speed = unknown_speed; + WAYPT_UNSET(WP, speed); track_add_wpt(TL, WP); } } @@ -796,7 +796,7 @@ static void trl_track_wpt(const waypoint *WP) { trklog = &(TRL.trklog[trk_idx]); trklog->pt[log_idx].x = deg2pt( WP->longitude); trklog->pt[log_idx].y = deg2pt(-WP->latitude); - if ( WP->speed != unknown_speed ) + if WAYPT_HAS(WP, speed) trklog->sh[log_idx].speed = mps2sp(WP->speed); if ( WP->altitude != unknown_alt ) trklog->sh[log_idx].height = m2hgt(WP->altitude); @@ -872,7 +872,7 @@ static void trl_write(void) { /**************************************************************************/ static void alan_rd_init(const char *fname) { - fin = gbfopen(fname, "r", MYNAME); + fin = gbfopen(fname, "rb", MYNAME); } static void alan_rd_deinit(void) { @@ -882,7 +882,7 @@ static void alan_rd_deinit(void) { static void alan_wr_init(const char *fname) { - fout = gbfopen(fname, "w", MYNAME); + fout = gbfopen(fname, "wb", MYNAME); } static void alan_wr_deinit(void) { diff --git a/an1.c b/an1.c index 684579598..e27603055 100644 --- a/an1.c +++ b/an1.c @@ -33,6 +33,7 @@ static FILE *outfile; static char *output_type = NULL; static char *road_changes = NULL; static char *nogc = NULL; +static char *nourl = NULL; static char *opt_symbol = NULL; static char *opt_color = NULL; static char *opt_zoom = NULL; @@ -64,6 +65,8 @@ arglist_t an1_args[] = { "", ARGTYPE_STRING, ARG_NOMINMAX }, {"nogc", &nogc, "Do not add geocache data to description", NULL, ARGTYPE_BOOL, ARG_NOMINMAX }, + {"nourl", &nourl, "Do not add URLs to description", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX }, {"deficon", &opt_symbol, "Symbol to use for point data", "Red Flag", ARGTYPE_STRING, ARG_NOMINMAX }, {"color", &opt_color, "Color for lines or mapnotes", @@ -797,7 +800,7 @@ Write_One_AN1_Waypoint( const waypoint *wpt ) xfree( extra ); } - if ( wpt->url ) { + if ( !nourl && wpt->url ) { int len = 7+strlen(wpt->url); char *extra = (char *)xmalloc( len ); sprintf( extra, "{URL=%s}", wpt->url ); diff --git a/axim_gpb.c b/axim_gpb.c index d7e70da6f..6d083cee8 100644 --- a/axim_gpb.c +++ b/axim_gpb.c @@ -87,12 +87,12 @@ decode_buff(const char *buff, route_head *track) /* These values can be, but must not be right. */ /* Further checks are needed to verify that. */ /* (!!! reference data !!!) */ - wpt->course = dir; + WAYPT_SET(wpt, course, dir); wpt->hdop = hdop; wpt->vdop = vdop; wpt->pdop = pdop; wpt->sat = sats; - wpt->speed = spd * 10; + WAYPT_SET(wpt, speed, spd * 10); #endif /* We don't have a header with some magic fixed numbers or strings. */ /* So let us check the range for some basic values */ diff --git a/bcr.c b/bcr.c index d212f3e3d..c9eaf340e 100644 --- a/bcr.c +++ b/bcr.c @@ -23,9 +23,11 @@ 2006/01/22: reader simplified with inifile library 2007/01/30: new option prefer_shortnames don't check global_opts.objective + 2007/04&14: new handling of DESCRIPTION lines */ #include "defs.h" +#include "csv_util.h" #include "garmin_tables.h" #include #include @@ -39,6 +41,9 @@ #undef BCR_DEBUG #define R_EARTH 6371000 /* radius of our big blue ball */ +#define BCR_DEF_ICON "Standort" +#define BCR_DEF_MPS_ICON "Waypoint" +#define BCR_UNKNOWN (double) 999999999 /* 6371014 would be a better value when converting to f.e. to mapsoure, @@ -71,13 +76,101 @@ arglist_t bcr_args[] = { ARG_TERMINATOR }; +typedef struct { + char *bcr_name; + char *mps_name; + char *symbol_DE; + int warned; +} bcr_icon_mapping_t; + +static +bcr_icon_mapping_t bcr_icon_mapping[] = { + { BCR_DEF_ICON, BCR_DEF_MPS_ICON, BCR_DEF_ICON }, + { "", BCR_DEF_MPS_ICON, "Eigene Adressen" }, + { "AdrMon alpen", "Summit", "Pass-Strassen" }, + { "AdrMon bauern", NULL, "Bauern- und Biohoefe" }, + { "AdrMon cmpngs", "Campground", "Campingplaetzte" }, + { "AdrMon p_aeu", "Scenic Area", "Sehenswertes" }, + { "AdrMon p_beu", "Gas Station", "Tanken" }, + { "AdrMon p_deu", "Parking Area", "Parken" }, + { "AdrMon p_feu", "Restaurant", "Gastro" }, + { "AdrMon p_geu", "Museum", "Freizeit" }, + { "AdrMon p_heu", "Gas Station", "Tankstellen" }, + { "AdrMon p_keu", NULL, "Faehrverbindungen" }, + { "AdrMon p_leu", NULL, "Grenzuebergaenge" }, + { "AdrMon p_teu", NULL, "Wein- und Sektgueter" }, + { "AdrMon RUINEN", "Ghost Town", "Burgen und Schloesser" }, + { "AdrMon NFHAUS", "Residence", "Naturfreundehaeuser" }, + { "AdrMon racing", "Bike Trail", "Rennstrecken" }, + { "AdrMon TNKRST", "Bar", "Tankraststaetten" }, + { "AdrMon tpclub", "Contact, Biker", "Motorrad-Clubs" }, + { "AdrMon tpequ", NULL, "Motorrad-Equipment" }, + { "AdrMon tphot", "Hotel", "Motorrad-Hotels" }, + { "AdrMon tpmh", NULL, "Motorradhaendler" }, + { "AdrMon tpss", "Restricted Area", "Sperrungen" }, + { "AdrMon tpsw", "Scenic Area", "Sehenswertes" }, + { "AdrMon tptref", NULL, "Treffpunkte" }, + { "AdrMon VORTE", "Information", "Ortsinformationen" }, + { "AdrMon WEBCAM", NULL, "WebCam-Standorte" }, + { "AdrMon youthh", NULL, "Jugendherbergen" }, + { "Town", "City (Small)", "Orte" }, + { NULL, NULL, NULL, 0 } +}; + +static void +bcr_handle_icon_str(const char *str, waypoint *wpt) +{ + bcr_icon_mapping_t *m; + + wpt->icon_descr = BCR_DEF_MPS_ICON; + + for (m = bcr_icon_mapping; (m->bcr_name); m++) { + if (case_ignore_strcmp(str, m->bcr_name) == 0) { + int nr; + + if (m->symbol_DE == NULL) { + if (! m->warned) { + m->warned = 1; + warning(MYNAME ": Unknown icon \"%s\" found. Please report.\n", str); + } + return; + } + wpt->description = xstrdup(m->symbol_DE); + if (m->mps_name != NULL) { + nr = gt_find_icon_number_from_desc(m->mps_name, MAPSOURCE); + wpt->icon_descr = gt_find_desc_from_icon_number(nr, MAPSOURCE, NULL); + } + return; + } + } +} + +static char * +get_bcr_icon_from_icon_descr(const char *icon_descr) +{ + char *result = BCR_DEF_ICON; + + if (icon_descr) { + bcr_icon_mapping_t *m; + + for (m = bcr_icon_mapping; (m->bcr_name); m++) { + if (! m->mps_name) continue; + if (case_ignore_strcmp(icon_descr, m->mps_name) == 0) { + result = m->bcr_name; + break; + } + } + } + return result; +} + static void bcr_init_radius(void) { if (radius_opt != NULL) /* preinitialize the earth radius */ { radius = atof(radius_opt); - if (radius < 0) + if (radius <= 0) fatal(MYNAME ": Sorry, the radius should be greater than zero!\n"); } else @@ -162,7 +255,6 @@ bcr_data_read(void) char station[32]; char *str; int mlat, mlon; /* mercator data */ - double xalt; waypoint *wpt; snprintf(station, sizeof(station), "STATION%d", index); @@ -184,23 +276,26 @@ bcr_data_read(void) if (cx == NULL) fatal(MYNAME ": structure error at %s (Client)!\n", station); *cx++ = '\0'; + bcr_handle_icon_str(str, wpt); + } + + if (NULL != (str = inifile_readstr(ini, "description", station))) { + char *c; - xalt = atof(cx); - if (xalt != 999999999) { - wpt->altitude = FEET_TO_METERS(xalt); + c = strchr(str, ','); + if (c != NULL) *c = '\0'; + if (*str) wpt->notes = xstrdup(str); + if ((str = c)) { + str++; + c = strchr(str, ','); + if (c != NULL) *c = '\0'; + if (*str) { + xfree(wpt->shortname); + wpt->shortname = xstrdup(str); + } } - - if (case_ignore_strcmp(str, "Standort") == 0) - wpt->icon_descr = gt_find_desc_from_icon_number(18, MAPSOURCE, NULL); - else if (case_ignore_strcmp(str, "Town") == 0) - wpt->icon_descr = gt_find_desc_from_icon_number(69, MAPSOURCE, NULL); - else - warning(MYNAME ": Unknown icon \"%s\" found. Please report.\n", str); } - if (NULL != (str = inifile_readstr(ini, "description", station))) - wpt->description = xstrdup(str); - route_add_wpt(route, wpt); } bcr_create_waypts_from_route(route); @@ -257,9 +352,8 @@ bcr_route_header(const route_head *route) { queue *elem, *tmp; waypoint *wpt; - char *c; - int i, icon, north, east, nmin, nmax, emin, emax; - char buff[128], symbol[32]; + char *sout; + int i, north, east, nmin, nmax, emin, emax; curr_rte_num++; if (curr_rte_num != target_rte_num) return; @@ -267,31 +361,28 @@ bcr_route_header(const route_head *route) bcr_write_line(fout, "[CLIENT]", NULL, NULL); /* client section */ bcr_write_line(fout, "REQUEST", NULL, "TRUE"); - c = route->rte_name; - if (rtename_opt != 0) c = rtename_opt; - if (c != NULL) - bcr_write_line(fout, "ROUTENAME", NULL, c); + sout = route->rte_name; + if (rtename_opt != 0) sout = rtename_opt; + if (sout != NULL) + bcr_write_line(fout, "ROUTENAME", NULL, sout); else bcr_write_line(fout, "ROUTENAME", NULL, "Route"); - bcr_write_line(fout, "DESCRIPTIONLINES", NULL, "1"); - bcr_write_line(fout, "DESCRIPTION1", NULL, ""); + bcr_write_line(fout, "DESCRIPTIONLINES", NULL, "0"); i = 0; - QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) { + char *icon; + waypoint *wpt = (waypoint *) elem; + i++; - wpt = (waypoint *) elem; - strncpy(symbol, "Standort", sizeof(symbol)); - if (wpt->icon_descr != 0) { - icon = gt_find_icon_number_from_desc(wpt->icon_descr, MAPSOURCE); - if ((icon >= 69) && (icon <= 72)) - strncpy(symbol, "Town", sizeof(symbol)); - } - snprintf(buff, sizeof(buff), "%s,%s", symbol, "999999999"); - bcr_write_line(fout, "STATION", &i, buff); + icon = get_bcr_icon_from_icon_descr(wpt->icon_descr); + + xasprintf(&sout, "%s,%.f", icon, BCR_UNKNOWN); + bcr_write_line(fout, "STATION", &i, sout); + xfree(sout); } bcr_write_line(fout, "[COORDINATES]", NULL, NULL); /* coords section */ @@ -312,8 +403,9 @@ bcr_route_header(const route_head *route) if (north < nmin) nmin = north; if (east < emin) emin = east; - snprintf(buff, sizeof(buff), "%d,%d", east, north); - bcr_write_line(fout, "STATION", &i, buff); + xasprintf(&sout, "%d,%d", east, north); + bcr_write_line(fout, "STATION", &i, sout); + xfree(sout); } bcr_write_line(fout, "[DESCRIPTION]", NULL, NULL); /* descr. section */ @@ -321,18 +413,40 @@ bcr_route_header(const route_head *route) i = 0; QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) { + char *s1, *s2, *sout; + i++; wpt = (waypoint *) elem; - c = wpt->description; - if (prefer_shortnames_opt || (c == NULL) || (*c == '\0')) - c = wpt->shortname; - bcr_write_line(fout, "STATION", &i, c); + s1 = wpt->notes; + if (s1 == NULL) s1 = wpt->description; + + if (prefer_shortnames_opt || (s1 == NULL) || (*s1 == '\0')) { + s2 = s1; + s1 = wpt->shortname; + } + else s2 = wpt->shortname; + + if (s1 == NULL) s1 = xstrdup(""); + else s1 = csv_stringclean(s1, ",\t\r\n"); + if (s2 == NULL) s2 = xstrdup(""); + else s2 = csv_stringclean(s2, ",\t\r\n"); + + if (*s2) + xasprintf(&sout, "%s,%s,@,0", s1, s2); + else + xasprintf(&sout, "%s,%s,@,0", s1, s1); + bcr_write_line(fout, "STATION", &i, sout); + + xfree(s1); + xfree(s2); + xfree(sout); } bcr_write_line(fout, "[ROUTE]", NULL, NULL); /* route section */ - snprintf(buff, sizeof(buff), "%d,%d,%d,%d", emin, nmax, emax, nmin); - bcr_write_line(fout, "ROUTERECT", NULL, buff); + xasprintf(&sout, "%d,%d,%d,%d", emin, nmax, emax, nmin); + bcr_write_line(fout, "ROUTERECT", NULL, sout); + xfree(sout); } diff --git a/brauniger_iq.c b/brauniger_iq.c index 30905e523..eef12030d 100644 --- a/brauniger_iq.c +++ b/brauniger_iq.c @@ -255,7 +255,7 @@ static arglist_t brauniger_iq_args[] = { ff_vecs_t brauniger_iq_vecs = { ff_type_serial, - FF_CAP_RW_ALL, + { ff_cap_none, ff_cap_read, ff_cap_none}, rd_init, NULL, rd_deinit, diff --git a/cet.c b/cet.c index 99a99a4f2..e003e57c5 100644 --- a/cet.c +++ b/cet.c @@ -51,12 +51,12 @@ cet_char_to_ucs4(const char src, const cet_cs_vec_t *vec, int *value) *dest = c; c -= vec->ucs4_offset; - if (c < 0) return CET_SUCESS; + if (c < 0) return CET_SUCCESS; else if ((c >= vec->ucs4_count) || (vec->ucs4_map[c] == -1)) return CET_ERROR; else { *dest = vec->ucs4_map[c]; - return CET_SUCESS; + return CET_SUCCESS; } } @@ -151,7 +151,7 @@ cet_utf8_to_ucs4(const char *str, int *bytes, int *value) { if (bytes != NULL) *bytes = 1; if (value != NULL) *value = *cp; - return CET_SUCESS; + return CET_SUCCESS; } else { @@ -178,7 +178,7 @@ cet_utf8_to_ucs4(const char *str, int *bytes, int *value) if (bytes != NULL) *bytes = len + 1; if (value != NULL) *value = res; - return CET_SUCESS; + return CET_SUCCESS; } } } @@ -235,8 +235,12 @@ cet_ucs4_to_char(const int value, const cet_cs_vec_t *vec) if (value < vec->ucs4_offset + vec->ucs4_count) return (char)value & 0xFF; - else - return CET_NOT_CONVERTABLE_DEFAULT; + else { + if (vec->fallback && (vec->fallback != vec)) + return cet_ucs4_to_char(value, vec->fallback); + else + return CET_NOT_CONVERTABLE_DEFAULT; + } } /* %%% cet_utf8_to_char %%% @@ -274,6 +278,7 @@ cet_str_utf8_to_any(const char *src, const cet_cs_vec_t *vec) char *res, *dest, *cend; if (c == NULL) return NULL; + if (vec->ucs4_count == 0) return xstrdup(src); /* UTF-8 -> UTF-8 */ len = strlen(c); res = dest = xmalloc(len + 1); /* target will become smaller or equal length */ diff --git a/cet.h b/cet.h index fdc702623..6b32f1edc 100644 --- a/cet.h +++ b/cet.h @@ -26,7 +26,7 @@ #include #define CET_ERROR 1 -#define CET_SUCESS 0 +#define CET_SUCCESS 0 typedef struct cet_ucs4_link_s { @@ -38,8 +38,8 @@ typedef struct cet_cs_vec_s { const char *name; /* name of character set */ const char **alias; /* alias table */ - int (*decode)(const char *, int *); /* ... to UCS-4 decoder !FUTURE! */ - short (*encode)(const int); /* UCS-4 to ... encoder !FUTURE! */ + struct cet_cs_vec_s *fallback; /* fallback character set */ + void *unused; const int *ucs4_map; /* char to UCS-4 value table */ const int ucs4_offset; /* first non standard character */ const int ucs4_count; /* values in table */ diff --git a/cet/ansi_x3_4_1968.h b/cet/ansi_x3_4_1968.h index 700c091b7..f8ce866aa 100644 --- a/cet/ansi_x3_4_1968.h +++ b/cet/ansi_x3_4_1968.h @@ -50,196 +50,392 @@ const cet_ucs4_link_t cet_ucs4_to_ansi_x3_4_1968_extra[] = /* !!! sorted by UCS-4 value !!! */ /* ------------------------------------------*/ { - {0x00c0, (unsigned char) 'A'}, // latin capital letter a with grave - {0x00c1, (unsigned char) 'A'}, // latin capital letter a with acute - {0x00C2, (unsigned char) 'A'}, // latin capital letter a with circumflex - {0x00C3, (unsigned char) 'A'}, // latin capital letter a with tilde - {0x00C4, (unsigned char) 'A'}, // latin capital letter a with diaeresis - {0x00C5, (unsigned char) 'A'}, // latin capital letter a with ring above - {0x00C7, (unsigned char) 'C'}, // latin capital letter c with cedilla - {0x00C8, (unsigned char) 'E'}, // latin capital letter e with grave - {0x00C9, (unsigned char) 'E'}, // latin capital letter e with acute - {0x00CA, (unsigned char) 'E'}, // latin capital letter e with circumflex - {0x00CB, (unsigned char) 'E'}, // latin capital letter e with diaeresis - {0x00CC, (unsigned char) 'I'}, // latin capital letter i with grave - {0x00CD, (unsigned char) 'I'}, // latin capital letter i with acute - {0x00CE, (unsigned char) 'I'}, // latin capital letter i with circumflex - {0x00CF, (unsigned char) 'I'}, // latin capital letter i with diaeresis - {0x00D1, (unsigned char) 'N'}, // latin capital letter n with tilde - {0x00D2, (unsigned char) 'O'}, // latin capital letter o with grave - {0x00D3, (unsigned char) 'O'}, // latin capital letter o with acute - {0x00D4, (unsigned char) 'O'}, // latin capital letter o with circumflex - {0x00D5, (unsigned char) 'O'}, // latin capital letter o with tilde - {0x00D6, (unsigned char) 'O'}, // latin capital letter o with diaeresis - {0x00D8, (unsigned char) 'O'}, // latin capital letter o with stroke - {0x00D9, (unsigned char) 'U'}, // latin capital letter u with grave - {0x00DA, (unsigned char) 'U'}, // latin capital letter u with acute - {0x00DB, (unsigned char) 'U'}, // latin capital letter u with circumflex - {0x00DC, (unsigned char) 'U'}, // latin capital letter u with diaeresis - {0x00DD, (unsigned char) 'Y'}, // latin capital letter y with acute - {0x00E0, (unsigned char) 'a'}, // latin small letter a with grave - {0x00E1, (unsigned char) 'a'}, // latin small letter a with acute - {0x00E2, (unsigned char) 'a'}, // latin small letter a with circumflex - {0x00E3, (unsigned char) 'a'}, // latin small letter a with tilde - {0x00E4, (unsigned char) 'a'}, // latin small letter a with diaeresis - {0x00E5, (unsigned char) 'a'}, // latin small letter a with ring above - {0x00E7, (unsigned char) 'c'}, // latin small letter c with cedilla - {0x00E8, (unsigned char) 'e'}, // latin small letter e with grave - {0x00E9, (unsigned char) 'e'}, // latin small letter e with acute - {0x00EA, (unsigned char) 'e'}, // latin small letter e with circumflex - {0x00EB, (unsigned char) 'e'}, // latin small letter e with diaeresis - {0x00EC, (unsigned char) 'i'}, // latin small letter i with grave - {0x00ED, (unsigned char) 'i'}, // latin small letter i with acute - {0x00EE, (unsigned char) 'i'}, // latin small letter i with circumflex - {0x00EF, (unsigned char) 'i'}, // latin small letter i with diaeresis - {0x00F1, (unsigned char) 'n'}, // latin small letter n with tilde - {0x00F2, (unsigned char) 'o'}, // latin small letter o with grave - {0x00F3, (unsigned char) 'o'}, // latin small letter o with acute - {0x00F4, (unsigned char) 'o'}, // latin small letter o with circumflex - {0x00F5, (unsigned char) 'o'}, // latin small letter o with tilde - {0x00F6, (unsigned char) 'o'}, // latin small letter o with diaeresis - {0x00F8, (unsigned char) 'o'}, // latin small letter o with stroke - {0x00F9, (unsigned char) 'u'}, // latin small letter u with grave - {0x00FA, (unsigned char) 'u'}, // latin small letter u with acute - {0x00FB, (unsigned char) 'u'}, // latin small letter u with circumflex - {0x00FC, (unsigned char) 'u'}, // latin small letter u with diaeresis - {0x00FD, (unsigned char) 'y'}, // latin small letter y with acute - {0x00FF, (unsigned char) 'y'}, // latin small letter y with diaeresis - {0x0100, (unsigned char) 'A'}, // latin capital letter a with macron - {0x0101, (unsigned char) 'a'}, // latin small letter a with macron - {0x0102, (unsigned char) 'A'}, // latin capital letter a with breve - {0x0103, (unsigned char) 'a'}, // latin small letter a with breve - {0x0104, (unsigned char) 'A'}, // latin capital letter a with ogonek - {0x0105, (unsigned char) 'a'}, // latin small letter a with ogonek - {0x0106, (unsigned char) 'C'}, // latin capital letter c with acute - {0x0107, (unsigned char) 'c'}, // latin small letter c with acute - {0x0108, (unsigned char) 'C'}, // latin capital letter c with circumflex - {0x0109, (unsigned char) 'c'}, // latin small letter c with circumflex - {0x010A, (unsigned char) 'C'}, // latin capital letter c with dot above - {0x010B, (unsigned char) 'c'}, // latin small letter c with dot above - {0x010C, (unsigned char) 'C'}, // latin capital letter c with caron - {0x010D, (unsigned char) 'c'}, // latin small letter c with caron - {0x010E, (unsigned char) 'D'}, // latin capital letter d with caron - {0x010F, (unsigned char) 'd'}, // latin small letter d with caron - {0x0110, (unsigned char) 'D'}, // latin capital letter d with stroke - {0x0111, (unsigned char) 'd'}, // latin small letter d with stroke - {0x0112, (unsigned char) 'E'}, // latin capital letter e with macron - {0x0113, (unsigned char) 'e'}, // latin small letter e with macron - {0x0116, (unsigned char) 'E'}, // latin capital letter e with dot above - {0x0117, (unsigned char) 'e'}, // latin small letter e with dot above - {0x0118, (unsigned char) 'E'}, // latin capital letter e with ogonek - {0x0119, (unsigned char) 'e'}, // latin small letter e with ogonek - {0x011A, (unsigned char) 'E'}, // latin capital letter e with caron - {0x011B, (unsigned char) 'e'}, // latin small letter e with caron - {0x011C, (unsigned char) 'G'}, // latin capital letter g with circumflex - {0x011D, (unsigned char) 'g'}, // latin small letter g with circumflex - {0x011E, (unsigned char) 'G'}, // latin capital letter g with breve - {0x011F, (unsigned char) 'g'}, // latin small letter g with breve - {0x0120, (unsigned char) 'G'}, // latin capital letter g with dot above - {0x0121, (unsigned char) 'g'}, // latin small letter g with dot above - {0x0122, (unsigned char) 'G'}, // latin capital letter g with cedilla - {0x0123, (unsigned char) 'g'}, // latin small letter g with cedilla - {0x0124, (unsigned char) 'H'}, // latin capital letter h with circumflex - {0x0125, (unsigned char) 'h'}, // latin small letter h with circumflex - {0x0126, (unsigned char) 'H'}, // latin capital letter h with stroke - {0x0127, (unsigned char) 'h'}, // latin small letter h with stroke - {0x0128, (unsigned char) 'I'}, // latin capital letter i with tilde - {0x0129, (unsigned char) 'i'}, // latin small letter i with tilde - {0x012A, (unsigned char) 'I'}, // latin capital letter i with macron - {0x012B, (unsigned char) 'i'}, // latin small letter i with macron - {0x012E, (unsigned char) 'I'}, // latin capital letter i with ogonek - {0x012F, (unsigned char) 'i'}, // latin small letter i with ogonek - {0x0130, (unsigned char) 'I'}, // latin capital letter i with dot above - {0x0134, (unsigned char) 'J'}, // latin capital letter j with circumflex - {0x0135, (unsigned char) 'j'}, // latin small letter j with circumflex - {0x0136, (unsigned char) 'K'}, // latin capital letter k with cedilla - {0x0137, (unsigned char) 'k'}, // latin small letter k with cedilla - {0x0139, (unsigned char) 'L'}, // latin capital letter l with acute - {0x013A, (unsigned char) 'l'}, // latin small letter l with acute - {0x013B, (unsigned char) 'L'}, // latin capital letter l with cedilla - {0x013C, (unsigned char) 'l'}, // latin small letter l with cedilla - {0x013D, (unsigned char) 'L'}, // latin capital letter l with caron - {0x013E, (unsigned char) 'l'}, // latin small letter l with caron - {0x0141, (unsigned char) 'L'}, // latin capital letter l with stroke - {0x0142, (unsigned char) 'l'}, // latin small letter l with stroke - {0x0143, (unsigned char) 'N'}, // latin capital letter n with acute - {0x0144, (unsigned char) 'n'}, // latin small letter n with acute - {0x0145, (unsigned char) 'N'}, // latin capital letter n with cedilla - {0x0146, (unsigned char) 'n'}, // latin small letter n with cedilla - {0x0147, (unsigned char) 'N'}, // latin capital letter n with caron - {0x0148, (unsigned char) 'n'}, // latin small letter n with caron - {0x014C, (unsigned char) 'O'}, // latin capital letter o with macron - {0x014D, (unsigned char) 'o'}, // latin small letter o with macron - {0x0150, (unsigned char) 'O'}, // latin capital letter o with double acute - {0x0151, (unsigned char) 'o'}, // latin small letter o with double acute - {0x0154, (unsigned char) 'R'}, // latin capital letter r with acute - {0x0155, (unsigned char) 'r'}, // latin small letter r with acute - {0x0156, (unsigned char) 'R'}, // latin capital letter r with cedilla - {0x0157, (unsigned char) 'r'}, // latin small letter r with cedilla - {0x0158, (unsigned char) 'R'}, // latin capital letter r with caron - {0x0159, (unsigned char) 'r'}, // latin small letter r with caron - {0x015A, (unsigned char) 'S'}, // latin capital letter s with acute - {0x015B, (unsigned char) 's'}, // latin small letter s with acute - {0x015C, (unsigned char) 'S'}, // latin capital letter s with circumflex - {0x015D, (unsigned char) 's'}, // latin small letter s with circumflex - {0x015E, (unsigned char) 'S'}, // latin capital letter s with cedilla - {0x015F, (unsigned char) 's'}, // latin small letter s with cedilla - {0x0160, (unsigned char) 'S'}, // latin capital letter s with caron - {0x0161, (unsigned char) 's'}, // latin small letter s with caron - {0x0162, (unsigned char) 'T'}, // latin capital letter t with cedilla - {0x0163, (unsigned char) 't'}, // latin small letter t with cedilla - {0x0164, (unsigned char) 'T'}, // latin capital letter t with caron - {0x0165, (unsigned char) 't'}, // latin small letter t with caron - {0x0166, (unsigned char) 'T'}, // latin capital letter t with stroke - {0x0167, (unsigned char) 't'}, // latin small letter t with stroke - {0x0168, (unsigned char) 'U'}, // latin capital letter u with tilde - {0x0169, (unsigned char) 'u'}, // latin small letter u with tilde - {0x016A, (unsigned char) 'U'}, // latin capital letter u with macron - {0x016B, (unsigned char) 'u'}, // latin small letter u with macron - {0x016C, (unsigned char) 'U'}, // latin capital letter u with breve - {0x016D, (unsigned char) 'u'}, // latin small letter u with breve - {0x016E, (unsigned char) 'U'}, // latin capital letter u with ring above - {0x016F, (unsigned char) 'u'}, // latin small letter u with ring above - {0x0170, (unsigned char) 'U'}, // latin capital letter u with double acute - {0x0171, (unsigned char) 'u'}, // latin small letter u with double acute - {0x0172, (unsigned char) 'U'}, // latin capital letter u with ogonek - {0x0173, (unsigned char) 'u'}, // latin small letter u with ogonek - {0x0174, (unsigned char) 'W'}, // latin capital letter w with circumflex - {0x0175, (unsigned char) 'w'}, // latin small letter w with circumflex - {0x0176, (unsigned char) 'Y'}, // latin capital letter y with circumflex - {0x0177, (unsigned char) 'y'}, // latin small letter y with circumflex - {0x0178, (unsigned char) 'Y'}, // latin capital letter y with diaeresis - {0x0179, (unsigned char) 'Z'}, // latin capital letter z with acute - {0x017A, (unsigned char) 'z'}, // latin small letter z with acute - {0x017B, (unsigned char) 'Z'}, // latin capital letter z with dot above - {0x017C, (unsigned char) 'z'}, // latin small letter z with dot above - {0x017D, (unsigned char) 'Z'}, // latin capital letter z with caron - {0x017E, (unsigned char) 'z'}, // latin small letter z with caron - {0x1E02, (unsigned char) 'B'}, // latin capital letter b with dot above - {0x1E03, (unsigned char) 'b'}, // latin small letter b with dot above - {0x1E0A, (unsigned char) 'D'}, // latin capital letter d with dot above - {0x1E0B, (unsigned char) 'd'}, // latin small letter d with dot above - {0x1E1E, (unsigned char) 'F'}, // latin capital letter f with dot above - {0x1E1F, (unsigned char) 'f'}, // latin small letter f with dot above - {0x1E40, (unsigned char) 'M'}, // latin capital letter m with dot above - {0x1E41, (unsigned char) 'm'}, // latin small letter m with dot above - {0x1E56, (unsigned char) 'P'}, // latin capital letter p with dot above - {0x1E57, (unsigned char) 'p'}, // latin small letter p with dot above - {0x1E60, (unsigned char) 'S'}, // latin capital letter s with dot above - {0x1E61, (unsigned char) 's'}, // latin small letter s with dot above - {0x1E6A, (unsigned char) 'T'}, // latin capital letter t with dot above - {0x1E6B, (unsigned char) 't'}, // latin small letter t with dot above - {0x1E80, (unsigned char) 'W'}, // latin capital letter w with grave - {0x1E81, (unsigned char) 'w'}, // latin small letter w with grave - {0x1E82, (unsigned char) 'W'}, // latin capital letter w with acute - {0x1E83, (unsigned char) 'w'}, // latin small letter w with acute - {0x1E84, (unsigned char) 'W'}, // latin capital letter w with diaeresis - {0x1E85, (unsigned char) 'w'}, // latin small letter w with diaeresis - {0x1e94, (unsigned char) 'u'}, - {0x1EF2, (unsigned char) 'Y'}, // latin capital letter y with grave - {0x1EF3, (unsigned char) 'y'}, // latin small letter y with grave - {0x201c, (unsigned char) '"'}, - {0x201d, (unsigned char) '"'} + {0x00C0, (unsigned char) 'A'}, // latin capital letter a with grave + {0x00C1, (unsigned char) 'A'}, // latin capital letter a with acute + {0x00C2, (unsigned char) 'A'}, // latin capital letter a with circumflex + {0x00C3, (unsigned char) 'A'}, // latin capital letter a with tilde + {0x00C4, (unsigned char) 'A'}, // latin capital letter a with diaeresis + {0x00C5, (unsigned char) 'A'}, // latin capital letter a with ring above + {0x00C7, (unsigned char) 'C'}, // latin capital letter c with cedilla + {0x00C8, (unsigned char) 'E'}, // latin capital letter e with grave + {0x00C9, (unsigned char) 'E'}, // latin capital letter e with acute + {0x00CA, (unsigned char) 'E'}, // latin capital letter e with circumflex + {0x00CB, (unsigned char) 'E'}, // latin capital letter e with diaeresis + {0x00CC, (unsigned char) 'I'}, // latin capital letter i with grave + {0x00CD, (unsigned char) 'I'}, // latin capital letter i with acute + {0x00CE, (unsigned char) 'I'}, // latin capital letter i with circumflex + {0x00CF, (unsigned char) 'I'}, // latin capital letter i with diaeresis + {0x00D1, (unsigned char) 'N'}, // latin capital letter n with tilde + {0x00D2, (unsigned char) 'O'}, // latin capital letter o with grave + {0x00D3, (unsigned char) 'O'}, // latin capital letter o with acute + {0x00D4, (unsigned char) 'O'}, // latin capital letter o with circumflex + {0x00D5, (unsigned char) 'O'}, // latin capital letter o with tilde + {0x00D6, (unsigned char) 'O'}, // latin capital letter o with diaeresis + {0x00D8, (unsigned char) 'O'}, // latin capital letter o with stroke + {0x00D9, (unsigned char) 'U'}, // latin capital letter u with grave + {0x00DA, (unsigned char) 'U'}, // latin capital letter u with acute + {0x00DB, (unsigned char) 'U'}, // latin capital letter u with circumflex + {0x00DC, (unsigned char) 'U'}, // latin capital letter u with diaeresis + {0x00DD, (unsigned char) 'Y'}, // latin capital letter y with acute + {0x00E0, (unsigned char) 'a'}, // latin small letter a with grave + {0x00E1, (unsigned char) 'a'}, // latin small letter a with acute + {0x00E2, (unsigned char) 'a'}, // latin small letter a with circumflex + {0x00E3, (unsigned char) 'a'}, // latin small letter a with tilde + {0x00E4, (unsigned char) 'a'}, // latin small letter a with diaeresis + {0x00E5, (unsigned char) 'a'}, // latin small letter a with ring above + {0x00E7, (unsigned char) 'c'}, // latin small letter c with cedilla + {0x00E8, (unsigned char) 'e'}, // latin small letter e with grave + {0x00E9, (unsigned char) 'e'}, // latin small letter e with acute + {0x00EA, (unsigned char) 'e'}, // latin small letter e with circumflex + {0x00EB, (unsigned char) 'e'}, // latin small letter e with diaeresis + {0x00EC, (unsigned char) 'i'}, // latin small letter i with grave + {0x00ED, (unsigned char) 'i'}, // latin small letter i with acute + {0x00EE, (unsigned char) 'i'}, // latin small letter i with circumflex + {0x00EF, (unsigned char) 'i'}, // latin small letter i with diaeresis + {0x00F1, (unsigned char) 'n'}, // latin small letter n with tilde + {0x00F2, (unsigned char) 'o'}, // latin small letter o with grave + {0x00F3, (unsigned char) 'o'}, // latin small letter o with acute + {0x00F4, (unsigned char) 'o'}, // latin small letter o with circumflex + {0x00F5, (unsigned char) 'o'}, // latin small letter o with tilde + {0x00F6, (unsigned char) 'o'}, // latin small letter o with diaeresis + {0x00F8, (unsigned char) 'o'}, // latin small letter o with stroke + {0x00F9, (unsigned char) 'u'}, // latin small letter u with grave + {0x00FA, (unsigned char) 'u'}, // latin small letter u with acute + {0x00FB, (unsigned char) 'u'}, // latin small letter u with circumflex + {0x00FC, (unsigned char) 'u'}, // latin small letter u with diaeresis + {0x00FD, (unsigned char) 'y'}, // latin small letter y with acute + {0x00FF, (unsigned char) 'y'}, // latin small letter y with diaeresis + {0x0100, (unsigned char) 'A'}, // latin capital letter a with macron + {0x0101, (unsigned char) 'a'}, // latin small letter a with macron + {0x0102, (unsigned char) 'A'}, // latin capital letter a with breve + {0x0103, (unsigned char) 'a'}, // latin small letter a with breve + {0x0104, (unsigned char) 'A'}, // latin capital letter a with ogonek + {0x0105, (unsigned char) 'a'}, // latin small letter a with ogonek + {0x0106, (unsigned char) 'C'}, // latin capital letter c with acute + {0x0107, (unsigned char) 'c'}, // latin small letter c with acute + {0x0108, (unsigned char) 'C'}, // latin capital letter c with circumflex + {0x0109, (unsigned char) 'c'}, // latin small letter c with circumflex + {0x010A, (unsigned char) 'C'}, // latin capital letter c with dot above + {0x010B, (unsigned char) 'c'}, // latin small letter c with dot above + {0x010C, (unsigned char) 'C'}, // latin capital letter c with caron + {0x010D, (unsigned char) 'c'}, // latin small letter c with caron + {0x010E, (unsigned char) 'D'}, // latin capital letter d with caron + {0x010F, (unsigned char) 'd'}, // latin small letter d with caron + {0x0110, (unsigned char) 'D'}, // latin capital letter d with stroke + {0x0111, (unsigned char) 'd'}, // latin small letter d with stroke + {0x0112, (unsigned char) 'E'}, // latin capital letter e with macron + {0x0113, (unsigned char) 'e'}, // latin small letter e with macron + {0x0114, (unsigned char) 'E'}, // latin capital letter e with breve + {0x0115, (unsigned char) 'e'}, // latin small letter e with breve + {0x0116, (unsigned char) 'E'}, // latin capital letter e with dot above + {0x0117, (unsigned char) 'e'}, // latin small letter e with dot above + {0x0118, (unsigned char) 'E'}, // latin capital letter e with ogonek + {0x0119, (unsigned char) 'e'}, // latin small letter e with ogonek + {0x011A, (unsigned char) 'E'}, // latin capital letter e with caron + {0x011B, (unsigned char) 'e'}, // latin small letter e with caron + {0x011C, (unsigned char) 'G'}, // latin capital letter g with circumflex + {0x011D, (unsigned char) 'g'}, // latin small letter g with circumflex + {0x011E, (unsigned char) 'G'}, // latin capital letter g with breve + {0x011F, (unsigned char) 'g'}, // latin small letter g with breve + {0x0120, (unsigned char) 'G'}, // latin capital letter g with dot above + {0x0121, (unsigned char) 'g'}, // latin small letter g with dot above + {0x0122, (unsigned char) 'G'}, // latin capital letter g with cedilla + {0x0123, (unsigned char) 'g'}, // latin small letter g with cedilla + {0x0124, (unsigned char) 'H'}, // latin capital letter h with circumflex + {0x0125, (unsigned char) 'h'}, // latin small letter h with circumflex + {0x0126, (unsigned char) 'H'}, // latin capital letter h with stroke + {0x0127, (unsigned char) 'h'}, // latin small letter h with stroke + {0x0128, (unsigned char) 'I'}, // latin capital letter i with tilde + {0x0129, (unsigned char) 'i'}, // latin small letter i with tilde + {0x012A, (unsigned char) 'I'}, // latin capital letter i with macron + {0x012B, (unsigned char) 'i'}, // latin small letter i with macron + {0x012C, (unsigned char) 'I'}, // latin capital letter i with breve + {0x012D, (unsigned char) 'i'}, // latin small letter i with breve + {0x012E, (unsigned char) 'I'}, // latin capital letter i with ogonek + {0x012F, (unsigned char) 'i'}, // latin small letter i with ogonek + {0x0130, (unsigned char) 'I'}, // latin capital letter i with dot above + {0x0131, (unsigned char) 'i'}, // latin small letter dotless i + {0x0134, (unsigned char) 'J'}, // latin capital letter j with circumflex + {0x0135, (unsigned char) 'j'}, // latin small letter j with circumflex + {0x0136, (unsigned char) 'K'}, // latin capital letter k with cedilla + {0x0137, (unsigned char) 'k'}, // latin small letter k with cedilla + {0x0139, (unsigned char) 'L'}, // latin capital letter l with acute + {0x013A, (unsigned char) 'l'}, // latin small letter l with acute + {0x013B, (unsigned char) 'L'}, // latin capital letter l with cedilla + {0x013C, (unsigned char) 'l'}, // latin small letter l with cedilla + {0x013D, (unsigned char) 'L'}, // latin capital letter l with caron + {0x013E, (unsigned char) 'l'}, // latin small letter l with caron + {0x0141, (unsigned char) 'L'}, // latin capital letter l with stroke + {0x0142, (unsigned char) 'l'}, // latin small letter l with stroke + {0x0143, (unsigned char) 'N'}, // latin capital letter n with acute + {0x0144, (unsigned char) 'n'}, // latin small letter n with acute + {0x0145, (unsigned char) 'N'}, // latin capital letter n with cedilla + {0x0146, (unsigned char) 'n'}, // latin small letter n with cedilla + {0x0147, (unsigned char) 'N'}, // latin capital letter n with caron + {0x0148, (unsigned char) 'n'}, // latin small letter n with caron + {0x014C, (unsigned char) 'O'}, // latin capital letter o with macron + {0x014D, (unsigned char) 'o'}, // latin small letter o with macron + {0x014E, (unsigned char) 'O'}, // latin capital letter o with breve + {0x014F, (unsigned char) 'o'}, // latin small letter o with breve + {0x0150, (unsigned char) 'O'}, // latin capital letter o with double acute + {0x0151, (unsigned char) 'o'}, // latin small letter o with double acute + {0x0152, (unsigned char) 'O'}, // latin capital ligature oe + {0x0153, (unsigned char) 'o'}, // latin small ligature oe + {0x0154, (unsigned char) 'R'}, // latin capital letter r with acute + {0x0155, (unsigned char) 'r'}, // latin small letter r with acute + {0x0156, (unsigned char) 'R'}, // latin capital letter r with cedilla + {0x0157, (unsigned char) 'r'}, // latin small letter r with cedilla + {0x0158, (unsigned char) 'R'}, // latin capital letter r with caron + {0x0159, (unsigned char) 'r'}, // latin small letter r with caron + {0x015A, (unsigned char) 'S'}, // latin capital letter s with acute + {0x015B, (unsigned char) 's'}, // latin small letter s with acute + {0x015C, (unsigned char) 'S'}, // latin capital letter s with circumflex + {0x015D, (unsigned char) 's'}, // latin small letter s with circumflex + {0x015E, (unsigned char) 'S'}, // latin capital letter s with cedilla + {0x015F, (unsigned char) 's'}, // latin small letter s with cedilla + {0x0160, (unsigned char) 'S'}, // latin capital letter s with caron + {0x0161, (unsigned char) 's'}, // latin small letter s with caron + {0x0162, (unsigned char) 'T'}, // latin capital letter t with cedilla + {0x0163, (unsigned char) 't'}, // latin small letter t with cedilla + {0x0164, (unsigned char) 'T'}, // latin capital letter t with caron + {0x0165, (unsigned char) 't'}, // latin small letter t with caron + {0x0166, (unsigned char) 'T'}, // latin capital letter t with stroke + {0x0167, (unsigned char) 't'}, // latin small letter t with stroke + {0x0168, (unsigned char) 'U'}, // latin capital letter u with tilde + {0x0169, (unsigned char) 'u'}, // latin small letter u with tilde + {0x016A, (unsigned char) 'U'}, // latin capital letter u with macron + {0x016B, (unsigned char) 'u'}, // latin small letter u with macron + {0x016C, (unsigned char) 'U'}, // latin capital letter u with breve + {0x016D, (unsigned char) 'u'}, // latin small letter u with breve + {0x016E, (unsigned char) 'U'}, // latin capital letter u with ring above + {0x016F, (unsigned char) 'u'}, // latin small letter u with ring above + {0x0170, (unsigned char) 'U'}, // latin capital letter u with double acute + {0x0171, (unsigned char) 'u'}, // latin small letter u with double acute + {0x0172, (unsigned char) 'U'}, // latin capital letter u with ogonek + {0x0173, (unsigned char) 'u'}, // latin small letter u with ogonek + {0x0174, (unsigned char) 'W'}, // latin capital letter w with circumflex + {0x0175, (unsigned char) 'w'}, // latin small letter w with circumflex + {0x0176, (unsigned char) 'Y'}, // latin capital letter y with circumflex + {0x0177, (unsigned char) 'y'}, // latin small letter y with circumflex + {0x0178, (unsigned char) 'Y'}, // latin capital letter y with diaeresis + {0x0179, (unsigned char) 'Z'}, // latin capital letter z with acute + {0x017A, (unsigned char) 'z'}, // latin small letter z with acute + {0x017B, (unsigned char) 'Z'}, // latin capital letter z with dot above + {0x017C, (unsigned char) 'z'}, // latin small letter z with dot above + {0x017D, (unsigned char) 'Z'}, // latin capital letter z with caron + {0x017E, (unsigned char) 'z'}, // latin small letter z with caron + {0x0180, (unsigned char) 'b'}, // latin small letter b with stroke + {0x0189, (unsigned char) 'D'}, // latin capital letter african d + {0x0191, (unsigned char) 'F'}, // latin capital letter f with hook + {0x0192, (unsigned char) 'f'}, // latin small letter f with hook + {0x0197, (unsigned char) 'I'}, // latin capital letter i with stroke + {0x019A, (unsigned char) 'l'}, // latin small letter l with bar + {0x019F, (unsigned char) 'O'}, // latin capital letter o with middle tilde + {0x01A0, (unsigned char) 'O'}, // latin capital letter o with horn + {0x01A1, (unsigned char) 'o'}, // latin small letter o with horn + {0x01AB, (unsigned char) 't'}, // latin small letter t with palatal hook + {0x01AE, (unsigned char) 'T'}, // latin capital letter t with retroflex hook + {0x01AF, (unsigned char) 'U'}, // latin capital letter u with horn + {0x01B0, (unsigned char) 'u'}, // latin small letter u with horn + {0x01B6, (unsigned char) 'z'}, // latin small letter z with stroke + {0x01C0, (unsigned char) '|'}, // latin letter dental click + {0x01C3, (unsigned char) '!'}, // latin letter retroflex click + {0x01CD, (unsigned char) 'A'}, // latin capital letter a with caron + {0x01CE, (unsigned char) 'a'}, // latin small letter a with caron + {0x01CF, (unsigned char) 'I'}, // latin capital letter i with caron + {0x01D0, (unsigned char) 'i'}, // latin small letter i with caron + {0x01D1, (unsigned char) 'O'}, // latin capital letter o with caron + {0x01D2, (unsigned char) 'o'}, // latin small letter o with caron + {0x01D3, (unsigned char) 'U'}, // latin capital letter u with caron + {0x01D4, (unsigned char) 'u'}, // latin small letter u with caron + {0x01D5, (unsigned char) 'U'}, // latin capital letter u with diaeresis and macron + {0x01D6, (unsigned char) 'u'}, // latin small letter u with diaeresis and macron + {0x01D7, (unsigned char) 'U'}, // latin capital letter u with diaeresis and acute + {0x01D8, (unsigned char) 'u'}, // latin small letter u with diaeresis and acute + {0x01D9, (unsigned char) 'U'}, // latin capital letter u with diaeresis and caron + {0x01DA, (unsigned char) 'u'}, // latin small letter u with diaeresis and caron + {0x01DB, (unsigned char) 'U'}, // latin capital letter u with diaeresis and grave + {0x01DC, (unsigned char) 'u'}, // latin small letter u with diaeresis and grave + {0x01DE, (unsigned char) 'A'}, // latin capital letter a with diaeresis and macron + {0x01DF, (unsigned char) 'a'}, // latin small letter a with diaeresis and macron + {0x01E4, (unsigned char) 'G'}, // latin capital letter g with stroke + {0x01E5, (unsigned char) 'g'}, // latin small letter g with stroke + {0x01E6, (unsigned char) 'G'}, // latin capital letter g with caron + {0x01E7, (unsigned char) 'g'}, // latin small letter g with caron + {0x01E8, (unsigned char) 'K'}, // latin capital letter k with caron + {0x01E9, (unsigned char) 'k'}, // latin small letter k with caron + {0x01EA, (unsigned char) 'O'}, // latin capital letter o with ogonek + {0x01EB, (unsigned char) 'o'}, // latin small letter o with ogonek + {0x01EC, (unsigned char) 'O'}, // latin capital letter o with ogonek and macron + {0x01ED, (unsigned char) 'o'}, // latin small letter o with ogonek and macron + {0x01F0, (unsigned char) 'j'}, // latin small letter j with caron + {0x0261, (unsigned char) 'g'}, // latin small letter script g + {0x02B9, (unsigned char) '\''}, // modifier letter prime + {0x02BA, (unsigned char) '"'}, // modifier letter double prime + {0x02BC, (unsigned char) '\''}, // modifier letter apostrophe + {0x02C4, (unsigned char) '^'}, // modifier letter up arrowhead + {0x02C6, (unsigned char) '^'}, // modifier letter circumflex accent + {0x02C7, (unsigned char) '^'}, // caron + {0x02C8, (unsigned char) '\''}, // modifier letter vertical line + {0x02CB, (unsigned char) '`'}, // modifier letter grave accent + {0x02CD, (unsigned char) '_'}, // modifier letter low macron + {0x02D8, (unsigned char) '^'}, // circumflex accent + {0x02D9, (unsigned char) '\''}, // dot above + {0x02DC, (unsigned char) '~'}, // small tilde + {0x0300, (unsigned char) '`'}, // combining grave accent + {0x0302, (unsigned char) '^'}, // combining circumflex accent + {0x0303, (unsigned char) '~'}, // combining tilde + {0x030E, (unsigned char) '"'}, // combining double vertical line above + {0x0331, (unsigned char) '_'}, // combining macron below + {0x0332, (unsigned char) '_'}, // combining low line + {0x037E, (unsigned char) ';'}, // greek question mark + {0x0393, (unsigned char) 'G'}, // greek capital letter gamma + {0x0398, (unsigned char) 'T'}, // greek capital letter theta + {0x03A3, (unsigned char) 'S'}, // greek capital letter sigma + {0x03A6, (unsigned char) 'F'}, // greek capital letter phi + {0x03A9, (unsigned char) 'O'}, // greek capital letter omega + {0x03B1, (unsigned char) 'a'}, // greek small letter alpha + {0x03B4, (unsigned char) 'd'}, // greek small letter delta + {0x03B5, (unsigned char) 'e'}, // greek small letter epsilon + {0x03C0, (unsigned char) 'p'}, // greek small letter pi + {0x03C3, (unsigned char) 's'}, // greek small letter sigma + {0x03C4, (unsigned char) 't'}, // greek small letter tau + {0x03C6, (unsigned char) 'f'}, // greek small letter phi + {0x04BB, (unsigned char) 'h'}, // cyrillic small letter shha + {0x0589, (unsigned char) ':'}, // armenian full stop + {0x066A, (unsigned char) '%'}, // arabic percent sign + {0x1E02, (unsigned char) 'B'}, // latin capital letter b with dot above + {0x1E03, (unsigned char) 'b'}, // latin small letter b with dot above + {0x1E0A, (unsigned char) 'D'}, // latin capital letter d with dot above + {0x1E0B, (unsigned char) 'd'}, // latin small letter d with dot above + {0x1E1E, (unsigned char) 'F'}, // latin capital letter f with dot above + {0x1E1F, (unsigned char) 'f'}, // latin small letter f with dot above + {0x1E40, (unsigned char) 'M'}, // latin capital letter m with dot above + {0x1E41, (unsigned char) 'm'}, // latin small letter m with dot above + {0x1E56, (unsigned char) 'P'}, // latin capital letter p with dot above + {0x1E57, (unsigned char) 'p'}, // latin small letter p with dot above + {0x1E60, (unsigned char) 'S'}, // latin capital letter s with dot above + {0x1E61, (unsigned char) 's'}, // latin small letter s with dot above + {0x1E6A, (unsigned char) 'T'}, // latin capital letter t with dot above + {0x1E6B, (unsigned char) 't'}, // latin small letter t with dot above + {0x1E80, (unsigned char) 'W'}, // latin capital letter w with grave + {0x1E81, (unsigned char) 'w'}, // latin small letter w with grave + {0x1E82, (unsigned char) 'W'}, // latin capital letter w with acute + {0x1E83, (unsigned char) 'w'}, // latin small letter w with acute + {0x1E84, (unsigned char) 'W'}, // latin capital letter w with diaeresis + {0x1E85, (unsigned char) 'w'}, // latin small letter w with diaeresis + {0x1E94, (unsigned char) 'u'}, + {0x1EF2, (unsigned char) 'Y'}, // latin capital letter y with grave + {0x1EF3, (unsigned char) 'y'}, // latin small letter y with grave + {0x2000, (unsigned char) ' '}, // en quad + {0x2001, (unsigned char) ' '}, // em quad + {0x2002, (unsigned char) ' '}, // en space + {0x2003, (unsigned char) ' '}, // em space + {0x2004, (unsigned char) ' '}, // three-per-em space + {0x2005, (unsigned char) ' '}, // four-per-em space + {0x2006, (unsigned char) ' '}, // six-per-em space + {0x2010, (unsigned char) '-'}, // hyphen + {0x2011, (unsigned char) '-'}, // non-breaking hyphen + {0x2017, (unsigned char) '='}, // double low line + {0x201C, (unsigned char) '"'}, + {0x201D, (unsigned char) '"'}, + {0x2032, (unsigned char) '\''}, // prime + {0x2035, (unsigned char) '`'}, // reversed prime + {0x203C, (unsigned char) '!'}, // double exclamation mark + {0x2044, (unsigned char) '/'}, // fraction slash + {0x2074, (unsigned char) '4'}, // superscript four + {0x2075, (unsigned char) '5'}, // superscript five + {0x2076, (unsigned char) '6'}, // superscript six + {0x2077, (unsigned char) '7'}, // superscript seven + {0x2078, (unsigned char) '8'}, // superscript eight + {0x207F, (unsigned char) 'n'}, // superscript latin small letter n + {0x2080, (unsigned char) '0'}, // subscript zero + {0x2081, (unsigned char) '1'}, // subscript one + {0x2082, (unsigned char) '2'}, // subscript two + {0x2083, (unsigned char) '3'}, // subscript three + {0x2084, (unsigned char) '4'}, // subscript four + {0x2085, (unsigned char) '5'}, // subscript five + {0x2086, (unsigned char) '6'}, // subscript six + {0x2087, (unsigned char) '7'}, // subscript seven + {0x2088, (unsigned char) '8'}, // subscript eight + {0x2089, (unsigned char) '9'}, // subscript nine + {0x20A7, (unsigned char) 'P'}, // peseta sign + {0x2102, (unsigned char) 'C'}, // double-struck capital c + {0x2107, (unsigned char) 'E'}, // euler constant + {0x210A, (unsigned char) 'g'}, // script small g + {0x210B, (unsigned char) 'H'}, // script capital h + {0x210C, (unsigned char) 'H'}, // black-letter capital h + {0x210D, (unsigned char) 'H'}, // double-struck capital h + {0x210E, (unsigned char) 'h'}, // planck constant + {0x2110, (unsigned char) 'I'}, // script capital i + {0x2111, (unsigned char) 'I'}, // black-letter capital i + {0x2112, (unsigned char) 'L'}, // script capital l + {0x2113, (unsigned char) 'l'}, // script small l + {0x2115, (unsigned char) 'N'}, // double-struck capital n + {0x2118, (unsigned char) 'P'}, // script capital p + {0x2119, (unsigned char) 'P'}, // double-struck capital p + {0x211A, (unsigned char) 'Q'}, // double-struck capital q + {0x211B, (unsigned char) 'R'}, // script capital r + {0x211C, (unsigned char) 'R'}, // black-letter capital r + {0x211D, (unsigned char) 'R'}, // double-struck capital r + {0x2124, (unsigned char) 'Z'}, // double-struck capital z + {0x2128, (unsigned char) 'Z'}, // black-letter capital z + {0x212A, (unsigned char) 'K'}, // kelvin sign + {0x212C, (unsigned char) 'B'}, // script capital b + {0x212D, (unsigned char) 'C'}, // black-letter capital c + {0x212E, (unsigned char) 'e'}, // estimated symbol + {0x212F, (unsigned char) 'e'}, // script small e + {0x2130, (unsigned char) 'E'}, // script capital e + {0x2131, (unsigned char) 'F'}, // script capital f + {0x2133, (unsigned char) 'M'}, // script capital m + {0x2134, (unsigned char) 'o'}, // script small o + {0x2190, (unsigned char) '<'}, // leftwards arrow + {0x2191, (unsigned char) '^'}, // upwards arrow + {0x2192, (unsigned char) '>'}, // rightwards arrow + {0x2193, (unsigned char) 'v'}, // downwards arrow + {0x2194, (unsigned char) '-'}, // left right arrow + {0x2195, (unsigned char) '|'}, // up down arrow + {0x21A8, (unsigned char) '|'}, // up down arrow with base + {0x2212, (unsigned char) '-'}, // minus sign + {0x2215, (unsigned char) '/'}, // division slash + {0x2216, (unsigned char) '\\'}, // set minus + {0x2217, (unsigned char) '*'}, // asterisk operator + {0x221A, (unsigned char) 'v'}, // square root + {0x221E, (unsigned char) '8'}, // infinity + {0x221F, (unsigned char) 'L'}, // right angle + {0x2223, (unsigned char) '|'}, // divides + {0x2229, (unsigned char) 'n'}, // intersection + {0x2236, (unsigned char) ':'}, // ratio + {0x223C, (unsigned char) '~'}, // tilde operator + {0x2261, (unsigned char) '='}, // identical to + {0x2264, (unsigned char) '='}, // less-than or equal to + {0x2265, (unsigned char) '='}, // greater-than or equal to + {0x2303, (unsigned char) '^'}, // up arrowhead + {0x2320, (unsigned char) '('}, // top half integral + {0x2321, (unsigned char) ')'}, // bottom half integral + {0x2329, (unsigned char) '<'}, // left-pointing angle bracket + {0x232A, (unsigned char) '>'}, // right-pointing angle bracket + {0x25AC, (unsigned char) '-'}, // black rectangle + {0x25B2, (unsigned char) '^'}, // black up-pointing triangle + {0x25BA, (unsigned char) '>'}, // black right-pointing pointer + {0x25C4, (unsigned char) '<'}, // black left-pointing pointer + {0x25CB, (unsigned char) '0'}, // white circle + {0x25D9, (unsigned char) '0'}, // inverse white circle + {0x263A, (unsigned char) 'O'}, // white smiling face + {0x263B, (unsigned char) 'O'}, // black smiling face + {0x263C, (unsigned char) '0'}, // white sun with rays + {0x2640, (unsigned char) '+'}, // female sign + {0x2642, (unsigned char) '>'}, // male sign + {0x266A, (unsigned char) 'd'}, // eighth note + {0x266B, (unsigned char) 'd'}, // beamed eighth notes + {0x2758, (unsigned char) '|'}, // light vertical bar + {0x3000, (unsigned char) ' '}, // ideographic space + {0x3008, (unsigned char) '<'}, // left angle bracket + {0x3009, (unsigned char) '>'}, // right angle bracket + {0x301A, (unsigned char) '['}, // left white square bracket + {0x301B, (unsigned char) ']'}, // right white square bracket + {0x301D, (unsigned char) '"'}, // reversed double prime quotation mark + {0x301E, (unsigned char) '"'} // double prime quotation mark }; cet_cs_vec_t cet_cs_vec_ansi_x3_4_1968 = /* defined in cet.h */ @@ -247,8 +443,8 @@ cet_cs_vec_t cet_cs_vec_ansi_x3_4_1968 = /* defined in cet.h */ cet_cs_name_ansi_x3_4_1968, /* name of character set */ cet_cs_alias_ansi_x3_4_1968, /* alias table */ - NULL, /* ... to UCS-4 converter (multi-byte) */ - NULL, /* UCS-4 to ... converter (multi-byte) */ + NULL, /* fallback character set */ + NULL, /* unused */ cet_ucs4_map_ansi_x3_4_1968, /* char to UCS-4 value table */ cet_ucs4_ofs_ansi_x3_4_1968, /* first non standard character */ diff --git a/cet/cp1250.h b/cet/cp1250.h index c16ba4d01..4c11b598d 100644 --- a/cet/cp1250.h +++ b/cet/cp1250.h @@ -135,10 +135,73 @@ const cet_ucs4_link_t cet_ucs4_to_cp1250_links[cet_ucs4_to_cp1250_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1250_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1250_extra[cet_ucs4_to_cp1250_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1250.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1250_extra[] = +{ + {0x0189, 0xd0} /* latin capital letter african d */, + {0x02bb, 0x91} /* modifier letter turned comma */, + {0x02c9, 0xaf} /* modifier letter macron */, + {0x02ca, 0xb4} /* modifier letter acute accent */, + {0x02da, 0xb0} /* ring above */, + {0x0301, 0xb4} /* combining acute accent */, + {0x0304, 0xaf} /* combining macron */, + {0x0305, 0xaf} /* combining overline */, + {0x0306, 0xa2} /* combining breve */, + {0x0307, 0xff} /* combining dot above */, + {0x0308, 0xa8} /* combining diaeresis */, + {0x030a, 0xb0} /* combining ring above */, + {0x030c, 0xa1} /* combining caron */, + {0x0327, 0xb8} /* combining cedilla */, + {0x03b2, 0xdf} /* greek small letter beta */, + {0x03bc, 0xb5} /* greek small letter mu */, + {0x2024, 0x95} /* one dot leader */, + {0x2033, 0x94} /* double prime */, + {0x2070, 0xb0} /* superscript zero */, + {0x20a4, 0xa3} /* lira sign */, + {0x212b, 0xc5} /* angstrom sign */, + {0x2190, 0x8b} /* leftwards arrow */, + {0x2192, 0x9b} /* rightwards arrow */, + {0x2193, 0xa1} /* downwards arrow */, + {0x2205, 0xd8} /* empty set */, + {0x2213, 0xb1} /* minus-or-plus sign */, + {0x2218, 0xb0} /* ring operator */, + {0x2219, 0x95} /* bullet operator */, + {0x226a, 0xab} /* much less-than */, + {0x226b, 0xbb} /* much greater-than */, + {0x22c5, 0xb7} /* dot operator */, + {0x2302, 0xa6} /* house */, + {0x2500, 0xa6} /* box drawings light horizontal */, + {0x2510, 0xac} /* box drawings light down and left */, + {0x2551, 0xa6} /* box drawings double vertical */, + {0x2557, 0xac} /* box drawings double down and left */, + {0x2560, 0xa6} /* box drawings double vertical and right */, + {0x2563, 0xa6} /* box drawings double vertical and left */, + {0x2569, 0xa6} /* box drawings double up and horizontal */, + {0x25a0, 0xa6} /* black square */, + {0x25bc, 0xa1} /* black down-pointing triangle */, + {0x25d8, 0x95} /* inverse bullet */, + {0x263a, 0xa2} /* white smiling face */, + {0x263b, 0xa2} /* black smiling face */, + {0x2660, 0xa6} /* black spade suit */, + {0x2663, 0xa6} /* black club suit */, + {0x2665, 0xa6} /* black heart suit */, + {0x2666, 0xa6} /* black diamond suit */, + {0x275b, 0x91} /* heavy single turned comma quotation mark ornament */, + {0x275c, 0x92} /* heavy single comma quotation mark ornament */, + {0x275d, 0x93} /* heavy double turned comma quotation mark ornament */, + {0x275e, 0x94} /* heavy double comma quotation mark ornament */, + {0x300a, 0xab} /* left double angle bracket */, + {0x300b, 0xbb} /* right double angle bracket */, + {0x301d, 0x93} /* reversed double prime quotation mark */, + {0x301e, 0x94} /* double prime quotation mark */, + {0x301f, 0x84} /* low double prime quotation mark */, + {0x30fb, 0xb7} /* katakana middle dot */, + {0x30fc, 0x97} /* katakana-hiragana prolonged sound mark */ +}; + +#define cet_ucs4_to_cp1250_extra_ct sizeof(cet_ucs4_to_cp1250_extra) / sizeof(cet_ucs4_to_cp1250_extra[0]) cet_cs_vec_t cet_cs_vec_cp1250 = /* defined in cet.h */ { @@ -155,8 +218,8 @@ cet_cs_vec_t cet_cs_vec_cp1250 = /* defined in cet.h */ cet_ucs4_to_cp1250_links, /* UCS-4 to char links */ cet_ucs4_to_cp1250_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1250_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1250_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1251.h b/cet/cp1251.h index efa2195c3..4fd0349ac 100644 --- a/cet/cp1251.h +++ b/cet/cp1251.h @@ -173,10 +173,44 @@ const cet_ucs4_link_t cet_ucs4_to_cp1251_links[cet_ucs4_to_cp1251_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1251_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1251_extra[cet_ucs4_to_cp1251_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1251.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1251_extra[] = +{ + {0x2195, 0xa6} /* up down arrow */, + {0x21a8, 0xa6} /* up down arrow with base */, + {0x2219, 0x95} /* bullet operator */, + {0x2302, 0xa6} /* house */, + {0x2502, 0xa6} /* box drawings light vertical */, + {0x2510, 0xac} /* box drawings light down and left */, + {0x2551, 0xa6} /* box drawings double vertical */, + {0x2553, 0xe3} /* box drawings down double and right single */, + {0x2554, 0xe3} /* box drawings double down and right */, + {0x2555, 0xac} /* box drawings down single and left double */, + {0x2556, 0xac} /* box drawings down double and left single */, + {0x2557, 0xac} /* box drawings double down and left */, + {0x255e, 0xa6} /* box drawings vertical single and right double */, + {0x255f, 0xa6} /* box drawings vertical double and right single */, + {0x2560, 0xa6} /* box drawings double vertical and right */, + {0x2561, 0xa6} /* box drawings vertical single and left double */, + {0x2562, 0xa6} /* box drawings vertical double and left single */, + {0x2563, 0xa6} /* box drawings double vertical and left */, + {0x2567, 0xa6} /* box drawings up single and horizontal double */, + {0x2568, 0xa6} /* box drawings up double and horizontal single */, + {0x2569, 0xa6} /* box drawings double up and horizontal */, + {0x258c, 0xa6} /* left half block */, + {0x2590, 0xa6} /* right half block */, + {0x25a0, 0xa6} /* black square */, + {0x25bc, 0xa1} /* black down-pointing triangle */, + {0x25d8, 0x95} /* inverse bullet */, + {0x2660, 0xa6} /* black spade suit */, + {0x2663, 0xa6} /* black club suit */, + {0x2665, 0xa6} /* black heart suit */, + {0x2666, 0xa6} /* black diamond suit */ +}; + +#define cet_ucs4_to_cp1251_extra_ct sizeof(cet_ucs4_to_cp1251_extra) / sizeof(cet_ucs4_to_cp1251_extra[0]) cet_cs_vec_t cet_cs_vec_cp1251 = /* defined in cet.h */ { @@ -193,8 +227,8 @@ cet_cs_vec_t cet_cs_vec_cp1251 = /* defined in cet.h */ cet_ucs4_to_cp1251_links, /* UCS-4 to char links */ cet_ucs4_to_cp1251_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1251_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1251_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1252.h b/cet/cp1252.h index 01f202325..f270bdb05 100644 --- a/cet/cp1252.h +++ b/cet/cp1252.h @@ -88,10 +88,64 @@ const cet_ucs4_link_t cet_ucs4_to_cp1252_links[cet_ucs4_to_cp1252_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1252_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1252_extra[cet_ucs4_to_cp1252_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1252.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1252_extra[] = +{ + {0x0110, 0xd0} /* latin capital letter d with stroke */, + {0x0189, 0xd0} /* latin capital letter african d */, + {0x0191, 0x83} /* latin capital letter f with hook */, + {0x02c9, 0xaf} /* modifier letter macron */, + {0x02ca, 0xb4} /* modifier letter acute accent */, + {0x02da, 0xb0} /* ring above */, + {0x0301, 0xb4} /* combining acute accent */, + {0x0304, 0xaf} /* combining macron */, + {0x0305, 0xaf} /* combining overline */, + {0x0308, 0xa8} /* combining diaeresis */, + {0x030a, 0xb0} /* combining ring above */, + {0x0327, 0xb8} /* combining cedilla */, + {0x03b2, 0xdf} /* greek small letter beta */, + {0x03bc, 0xb5} /* greek small letter mu */, + {0x2024, 0xb7} /* one dot leader */, + {0x2070, 0xb0} /* superscript zero */, + {0x20a1, 0xa2} /* colon sign */, + {0x20a4, 0xa3} /* lira sign */, + {0x212b, 0xc5} /* angstrom sign */, + {0x2205, 0xd8} /* empty set */, + {0x2213, 0xb1} /* minus-or-plus sign */, + {0x2218, 0xb0} /* ring operator */, + {0x2219, 0xb7} /* bullet operator */, + {0x2248, 0x98} /* almost equal to */, + {0x226a, 0xab} /* much less-than */, + {0x226b, 0xbb} /* much greater-than */, + {0x22c5, 0xb7} /* dot operator */, + {0x2302, 0xa6} /* house */, + {0x2310, 0xac} /* reversed not sign */, + {0x2502, 0xa6} /* box drawings light vertical */, + {0x2524, 0xa6} /* box drawings light vertical and left */, + {0x2551, 0xa6} /* box drawings double vertical */, + {0x255e, 0xa6} /* box drawings vertical single and right double */, + {0x255f, 0xa6} /* box drawings vertical double and right single */, + {0x2560, 0xa6} /* box drawings double vertical and right */, + {0x2561, 0xa6} /* box drawings vertical single and left double */, + {0x2562, 0xa6} /* box drawings vertical double and left single */, + {0x2563, 0xa6} /* box drawings double vertical and left */, + {0x2580, 0xaf} /* upper half block */, + {0x2588, 0xa6} /* full block */, + {0x258c, 0xa6} /* left half block */, + {0x2590, 0xa6} /* right half block */, + {0x2591, 0xa6} /* light shade */, + {0x2592, 0xa6} /* medium shade */, + {0x2593, 0xa6} /* dark shade */, + {0x25a0, 0xa6} /* black square */, + {0x263c, 0xa4} /* white sun with rays */, + {0x300a, 0xab} /* left double angle bracket */, + {0x300b, 0xbb} /* right double angle bracket */, + {0x30fb, 0xb7} /* katakana middle dot */ +}; + +#define cet_ucs4_to_cp1252_extra_ct sizeof(cet_ucs4_to_cp1252_extra) / sizeof(cet_ucs4_to_cp1252_extra[0]) cet_cs_vec_t cet_cs_vec_cp1252 = /* defined in cet.h */ { @@ -108,8 +162,8 @@ cet_cs_vec_t cet_cs_vec_cp1252 = /* defined in cet.h */ cet_ucs4_to_cp1252_links, /* UCS-4 to char links */ cet_ucs4_to_cp1252_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1252_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1252_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1253.h b/cet/cp1253.h index 727139847..7f4a1b7f9 100644 --- a/cet/cp1253.h +++ b/cet/cp1253.h @@ -151,10 +151,33 @@ const cet_ucs4_link_t cet_ucs4_to_cp1253_links[cet_ucs4_to_cp1253_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1253_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1253_extra[cet_ucs4_to_cp1253_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1253.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1253_extra[] = +{ + {0x0191, 0x83} /* latin capital letter f with hook */, + {0x030d, 0xb4} /* combining vertical line above */, + {0x2195, 0xa6} /* up down arrow */, + {0x21a8, 0xa6} /* up down arrow with base */, + {0x2302, 0xa6} /* house */, + {0x2502, 0xa6} /* box drawings light vertical */, + {0x2510, 0xac} /* box drawings light down and left */, + {0x2551, 0xa6} /* box drawings double vertical */, + {0x2557, 0xac} /* box drawings double down and left */, + {0x2560, 0xa6} /* box drawings double vertical and right */, + {0x2563, 0xa6} /* box drawings double vertical and left */, + {0x2569, 0xa6} /* box drawings double up and horizontal */, + {0x25a0, 0xa6} /* black square */, + {0x25bc, 0xa1} /* black down-pointing triangle */, + {0x25d8, 0x95} /* inverse bullet */, + {0x2660, 0xa6} /* black spade suit */, + {0x2663, 0xa6} /* black club suit */, + {0x2665, 0xa6} /* black heart suit */, + {0x2666, 0xa6} /* black diamond suit */ +}; + +#define cet_ucs4_to_cp1253_extra_ct sizeof(cet_ucs4_to_cp1253_extra) / sizeof(cet_ucs4_to_cp1253_extra[0]) cet_cs_vec_t cet_cs_vec_cp1253 = /* defined in cet.h */ { @@ -171,8 +194,8 @@ cet_cs_vec_t cet_cs_vec_cp1253 = /* defined in cet.h */ cet_ucs4_to_cp1253_links, /* UCS-4 to char links */ cet_ucs4_to_cp1253_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1253_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1253_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1254.h b/cet/cp1254.h index 55b75b6db..085320898 100644 --- a/cet/cp1254.h +++ b/cet/cp1254.h @@ -95,10 +95,75 @@ const cet_ucs4_link_t cet_ucs4_to_cp1254_links[cet_ucs4_to_cp1254_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1254_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1254_extra[cet_ucs4_to_cp1254_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1254.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1254_extra[] = +{ + {0x0191, 0x83} /* latin capital letter f with hook */, + {0x02bb, 0x91} /* modifier letter turned comma */, + {0x02c9, 0xaf} /* modifier letter macron */, + {0x02ca, 0xb4} /* modifier letter acute accent */, + {0x02da, 0xb0} /* ring above */, + {0x02db, 0xb8} /* ogonek */, + {0x02dd, 0xa8} /* double acute accent */, + {0x0301, 0xb4} /* combining acute accent */, + {0x0303, 0x98} /* combining tilde */, + {0x0304, 0xaf} /* combining macron */, + {0x0305, 0xaf} /* combining overline */, + {0x0306, 0x88} /* combining breve */, + {0x0307, 0xb7} /* combining dot above */, + {0x0308, 0xa8} /* combining diaeresis */, + {0x030a, 0xa7} /* combining ring above */, + {0x030c, 0x88} /* combining caron */, + {0x030e, 0xa8} /* combining double vertical line above */, + {0x0327, 0xb8} /* combining cedilla */, + {0x03b2, 0xdf} /* greek small letter beta */, + {0x03bc, 0xb5} /* greek small letter mu */, + {0x2024, 0x95} /* one dot leader */, + {0x2033, 0xa8} /* double prime */, + {0x2070, 0xb0} /* superscript zero */, + {0x2080, 0xb0} /* subscript zero */, + {0x2082, 0xb2} /* subscript two */, + {0x2083, 0xb3} /* subscript three */, + {0x20a4, 0xa3} /* lira sign */, + {0x212b, 0xc5} /* angstrom sign */, + {0x2190, 0x8b} /* leftwards arrow */, + {0x2192, 0x9b} /* rightwards arrow */, + {0x2205, 0xd8} /* empty set */, + {0x2213, 0xb1} /* minus-or-plus sign */, + {0x2218, 0xb0} /* ring operator */, + {0x2219, 0x95} /* bullet operator */, + {0x226a, 0xab} /* much less-than */, + {0x226b, 0xbb} /* much greater-than */, + {0x22c5, 0xb7} /* dot operator */, + {0x2302, 0xa6} /* house */, + {0x2500, 0xa6} /* box drawings light horizontal */, + {0x2510, 0xac} /* box drawings light down and left */, + {0x2551, 0xa6} /* box drawings double vertical */, + {0x2557, 0xac} /* box drawings double down and left */, + {0x2560, 0xa6} /* box drawings double vertical and right */, + {0x2563, 0xa6} /* box drawings double vertical and left */, + {0x2569, 0xa6} /* box drawings double up and horizontal */, + {0x25a0, 0xa6} /* black square */, + {0x25bc, 0xa1} /* black down-pointing triangle */, + {0x25d8, 0x95} /* inverse bullet */, + {0x2660, 0xa6} /* black spade suit */, + {0x2663, 0xa6} /* black club suit */, + {0x2665, 0xa6} /* black heart suit */, + {0x2666, 0xa6} /* black diamond suit */, + {0x275b, 0x91} /* heavy single turned comma quotation mark ornament */, + {0x275c, 0x92} /* heavy single comma quotation mark ornament */, + {0x275d, 0x93} /* heavy double turned comma quotation mark ornament */, + {0x275e, 0x94} /* heavy double comma quotation mark ornament */, + {0x300a, 0xab} /* left double angle bracket */, + {0x300b, 0xbb} /* right double angle bracket */, + {0x301f, 0x84} /* low double prime quotation mark */, + {0x30fb, 0xb7} /* katakana middle dot */, + {0x30fc, 0x97} /* katakana-hiragana prolonged sound mark */ +}; + +#define cet_ucs4_to_cp1254_extra_ct sizeof(cet_ucs4_to_cp1254_extra) / sizeof(cet_ucs4_to_cp1254_extra[0]) cet_cs_vec_t cet_cs_vec_cp1254 = /* defined in cet.h */ { @@ -115,8 +180,8 @@ cet_cs_vec_t cet_cs_vec_cp1254 = /* defined in cet.h */ cet_ucs4_to_cp1254_links, /* UCS-4 to char links */ cet_ucs4_to_cp1254_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1254_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1254_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1255.h b/cet/cp1255.h index d80498da3..c078cefa3 100644 --- a/cet/cp1255.h +++ b/cet/cp1255.h @@ -112,10 +112,42 @@ const cet_ucs4_link_t cet_ucs4_to_cp1255_links[cet_ucs4_to_cp1255_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1255_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1255_extra[cet_ucs4_to_cp1255_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1255.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1255_extra[] = +{ + {0x02c6, 0x88} /* modifier letter circumflex */, + {0x02dc, 0x98} /* spacing tilde */, + {0x05b0, 0xc0} /* hebrew point sheva */, + {0x05b1, 0xc1} /* hebrew point hataf segol */, + {0x05b2, 0xc2} /* hebrew point hataf patah */, + {0x05b3, 0xc3} /* hebrew point hataf qamats */, + {0x05b4, 0xc4} /* hebrew point hiriq */, + {0x05b5, 0xc5} /* hebrew point tsere */, + {0x05b6, 0xc6} /* hebrew point segol */, + {0x05b7, 0xc7} /* hebrew point patah */, + {0x05b8, 0xc8} /* hebrew point qamats */, + {0x05b9, 0xc9} /* hebrew point holam */, + {0x05ba, 0xca} /* hebrew point ???? */, + {0x05bb, 0xcb} /* hebrew point qubuts */, + {0x05bc, 0xcc} /* hebrew point dagesh */, + {0x05bd, 0xcd} /* hebrew point meteg */, + {0x05be, 0xce} /* hebrew punctuation maqaf */, + {0x05bf, 0xcf} /* hebrew point rafe */, + {0x05c0, 0xd0} /* hebrew point paseq */, + {0x05c1, 0xd1} /* hebrew point shin dot */, + {0x05c2, 0xd2} /* hebrew point sin dot */, + {0x05c3, 0xd3} /* hebrew punctuation sof pasuq */, + {0x05f0, 0xd4} /* hebrew ligature yiddish double vav */, + {0x05f1, 0xd5} /* hebrew ligature yiddish vav yod */, + {0x05f2, 0xd6} /* hebrew ligature yiddish double yod */, + {0x05f3, 0xd7} /* hebrew punctuation geresh */, + {0x05f4, 0xd8} /* hebrew punctuation gershayim */, + {0x20aa, 0xa4} /* new sheqel sign */ +}; + +#define cet_ucs4_to_cp1255_extra_ct sizeof(cet_ucs4_to_cp1255_extra) / sizeof(cet_ucs4_to_cp1255_extra[0]) cet_cs_vec_t cet_cs_vec_cp1255 = /* defined in cet.h */ { @@ -132,8 +164,8 @@ cet_cs_vec_t cet_cs_vec_cp1255 = /* defined in cet.h */ cet_ucs4_to_cp1255_links, /* UCS-4 to char links */ cet_ucs4_to_cp1255_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1255_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1255_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1256.h b/cet/cp1256.h index b4d8941c5..89bc69652 100644 --- a/cet/cp1256.h +++ b/cet/cp1256.h @@ -142,10 +142,32 @@ const cet_ucs4_link_t cet_ucs4_to_cp1256_links[cet_ucs4_to_cp1256_ct] = {0x3113, 0xd0} /* letter zh */ }; -/* -#define cet_ucs4_to_cp1256_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1256_extra[cet_ucs4_to_cp1256_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1256.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1256_extra[] = +{ + {0x0152, 0x8c} /* latin capital letter o e */, + {0x0153, 0x9c} /* latin small letter o e */, + {0x0192, 0x83} /* latin small letter script f */, + {0x02c6, 0x88} /* modifier letter circumflex */, + {0x060c, 0xa1} /* arabic comma */, + {0x0638, 0xd9} /* arabic letter dhah */, + {0x0679, 0x8a} /* arabic letter tteh */, + {0x0688, 0x8f} /* arabic letter ddal */, + {0x0691, 0x9a} /* arabic letter rreh */, + {0x06a9, 0x98} /* arabic letter keheh */, + {0x06ba, 0x9f} /* arabic letter noon ghunna */, + {0x06be, 0xaa} /* arabic letter heh doachashmee */, + {0x06c1, 0xc0} /* arabic letter heh goal */, + {0x06cc, 0xed} /* best-fit : farsi yeh -> arabic yeh (u+064a) */, + {0x06d2, 0xff} /* arabic letter yeh barree */, + {0x200c, 0x9d} /* zero width non-joiner */, + {0x200d, 0x9e} /* zero width joiner */, + {0x2030, 0x89} /* per mille sign */ +}; + +#define cet_ucs4_to_cp1256_extra_ct sizeof(cet_ucs4_to_cp1256_extra) / sizeof(cet_ucs4_to_cp1256_extra[0]) cet_cs_vec_t cet_cs_vec_cp1256 = /* defined in cet.h */ { @@ -162,8 +184,8 @@ cet_cs_vec_t cet_cs_vec_cp1256 = /* defined in cet.h */ cet_ucs4_to_cp1256_links, /* UCS-4 to char links */ cet_ucs4_to_cp1256_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1256_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1256_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet/cp1257.h b/cet/cp1257.h index 3e9355fd1..a629396cc 100644 --- a/cet/cp1257.h +++ b/cet/cp1257.h @@ -130,10 +130,17 @@ const cet_ucs4_link_t cet_ucs4_to_cp1257_links[cet_ucs4_to_cp1257_ct] = {0x2122, 0x99} /* mark sign */ }; -/* -#define cet_ucs4_to_cp1257_extra_ct 0 -const cet_ucs4_link_t cet_ucs4_to_cp1257_extra[cet_ucs4_to_cp1257_extra_ct] = {}; -*/ +/* Extra table was generated from bestfit1257.txt located at + ftp.unicode.org:/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/ */ + +const cet_ucs4_link_t cet_ucs4_to_cp1257_extra[] = +{ + {0x02c7, 0x8e} /* hacek */, + {0x02d9, 0xff} /* dot above */, + {0x02db, 0x9e} /* ogonek */, +}; + +#define cet_ucs4_to_cp1257_extra_ct sizeof(cet_ucs4_to_cp1257_extra) / sizeof(cet_ucs4_to_cp1257_extra[0]) cet_cs_vec_t cet_cs_vec_cp1257 = /* defined in cet.h */ { @@ -150,8 +157,8 @@ cet_cs_vec_t cet_cs_vec_cp1257 = /* defined in cet.h */ cet_ucs4_to_cp1257_links, /* UCS-4 to char links */ cet_ucs4_to_cp1257_ct, /* number of links */ - NULL, /* hand made UCS-4 links */ - 0, /* number of extra links */ + cet_ucs4_to_cp1257_extra, /* hand made UCS-4 links */ + cet_ucs4_to_cp1257_extra_ct, /* number of extra links */ NULL /* for internal use */ }; diff --git a/cet_util.c b/cet_util.c index ad9b68f6f..19e76f24d 100644 --- a/cet_util.c +++ b/cet_util.c @@ -2,7 +2,7 @@ Character encoding transformation - utilities - Copyright (C) 2005 Olaf Klein, o.b.klein@gpsbabel.org + Copyright (C) 2005,2006,2007 Olaf Klein, o.b.klein@gpsbabel.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,9 +49,15 @@ static int cet_cs_alias_ct = 0; static int cet_cs_vec_ct = 0; static int cet_output = 0; -/* %%% short hand strings transmission for main character sets %%% */ +/* %%% fixed inbuild character sets %%% */ +#include "cet/ansi_x3_4_1968.h" #include "cet/iso_8859_1.h" +#include "cet/iso_8859_15.h" +#include "cet/cp1252.h" + +/* %%% short hand strings transmission for main character sets %%% */ + char * cet_str_utf8_to_iso8859_1(const char *src) { @@ -64,8 +70,6 @@ cet_str_iso8859_1_to_utf8(const char *src) return cet_str_any_to_utf8(src, &cet_cs_vec_iso_8859_1); } -#include "cet/iso_8859_15.h" - char * cet_str_utf8_to_iso8859_15(const char *src) { @@ -78,8 +82,6 @@ cet_str_iso8859_15_to_utf8(const char *src) return cet_str_any_to_utf8(src, &cet_cs_vec_iso_8859_15); } -#include "cet/ansi_x3_4_1968.h" - char * cet_str_utf8_to_us_ascii(const char *src) { @@ -92,8 +94,6 @@ cet_str_us_ascii_to_utf8(const char *src) return cet_str_any_to_utf8(src, &cet_cs_vec_ansi_x3_4_1968); } -#include "cet/cp1252.h" - char * cet_str_utf8_to_cp1252(const char *src) { @@ -333,7 +333,7 @@ void cet_check_cs(cet_cs_vec_t *vec) /* test well sorted link & extra tables */ { cet_ucs4_link_t *link; - + if ((link = (cet_ucs4_link_t *)vec->ucs4_link)) { int i, j; @@ -810,10 +810,28 @@ cet_register_cs(&cet_cs_vec_vps); qsort(list, c, sizeof(*list), cet_cs_alias_qsort_cb); cet_cs_alias = list; cet_cs_alias_ct = c; + + /* install fallback for ascii-like (first 128 ch.) character sets */ + for (i = 1250; i <= 1258; i++) { + char name[16]; + cet_cs_vec_t *vec; + + snprintf(name, sizeof(name), "WIN-CP%d", i); + if ((vec = cet_find_cs_by_name(name))) + vec->fallback = &cet_cs_vec_ansi_x3_4_1968; + } + for (i = 1; i <= 15; i++) { + char name[16]; + cet_cs_vec_t *vec; + + snprintf(name, sizeof(name), "ISO-8859-%d", i); + if ((vec = cet_find_cs_by_name(name))) + vec->fallback = &cet_cs_vec_ansi_x3_4_1968; + } + } #ifdef CET_DEBUG printf("We have registered %d character sets with %d aliases\n", cet_cs_vec_ct, cet_cs_alias_ct); #endif - } } cet_cs_vec_t * @@ -908,6 +926,28 @@ cet_convert_init(const char *cs_name, const int force) } } +/* -------------------------------------------------------------------- */ + +static void +cet_flag_waypt(const waypoint *wpt) +{ + ((waypoint *)(wpt))->wpt_flags.cet_converted = 1; +} + +static void +cet_flag_route(const route_head *rte) +{ + ((route_head *)(rte))->cet_converted = 1; +} + +static void +cet_flag_all(void) +{ + waypt_disp_all(cet_flag_waypt); + route_disp_all(cet_flag_route, NULL, cet_flag_waypt); + track_disp_all(cet_flag_route, NULL, cet_flag_waypt); +} + /* -------------------------------------------------------------------- */ /* %%% complete data strings transformation %%% */ /* -------------------------------------------------------------------- */ @@ -950,6 +990,7 @@ cet_convert_waypt(const waypoint *wpt) { waypoint *w = (waypoint *)wpt; format_specific_data *fs; + url_link *url_next; if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) return; @@ -960,6 +1001,10 @@ cet_convert_waypt(const waypoint *wpt) w->notes = cet_convert_string(wpt->notes); w->url = cet_convert_string(wpt->url); w->url_link_text = cet_convert_string(wpt->url_link_text); + for (url_next = w->url_next; url_next; url_next = url_next->url_next) { + url_next->url = cet_convert_string(url_next->url); + url_next->url_link_text = cet_convert_string(url_next->url_link_text); + } fs = wpt->fs; while (fs != NULL) @@ -1008,25 +1053,30 @@ cet_convert_strings(const cet_cs_vec_t *source, const cet_cs_vec_t *target, cons if ((source == NULL) || (source == &cet_cs_vec_utf8)) { - if ((target == NULL) || (target == &cet_cs_vec_utf8)) return; /* Nothing to do */ - - cet_output = 1; + if ((target == NULL) || (target == &cet_cs_vec_utf8)) { + cet_flag_all(); + return; + } - converter = cet_convert_from_utf8; - cs_name_from = (char *)cet_cs_vec_utf8.name; - cs_name_to = (char *)target->name; + cet_output = 1; + + converter = cet_convert_from_utf8; + cs_name_from = (char *)cet_cs_vec_utf8.name; + cs_name_to = (char *)target->name; } - else - { - if ((target != NULL) && (target != &cet_cs_vec_utf8)) - fatal(MYNAME ": Internal error!\n"); - converter = cet_convert_to_utf8; - cs_name_to = (char *)cet_cs_vec_utf8.name; - cs_name_from = (char *)source->name; + else { + if ((target != NULL) && (target != &cet_cs_vec_utf8)) + fatal(MYNAME ": Internal error!\n"); + + cet_output = 0; + + converter = cet_convert_to_utf8; + cs_name_to = (char *)cet_cs_vec_utf8.name; + cs_name_from = (char *)source->name; } if (global_opts.debug_level > 0) - printf(MYNAME ": Converting from \"%s\" to \"%s\"", cs_name_from, cs_name_to); + printf(MYNAME ": Converting from \"%s\" to \"%s\"", cs_name_from, cs_name_to); waypt_disp_all(cet_convert_waypt); route_disp_all(cet_convert_route_hdr, cet_convert_route_tlr, cet_convert_waypt); @@ -1035,7 +1085,7 @@ cet_convert_strings(const cet_cs_vec_t *source, const cet_cs_vec_t *target, cons cet_output = 0; if (global_opts.debug_level > 0) - printf(", done.\n"); + printf(", done.\n"); } /* %%% cet_disp_character_set_names %%% diff --git a/cetus.c b/cetus.c index 406824e02..8617a2995 100644 --- a/cetus.c +++ b/cetus.c @@ -30,9 +30,8 @@ #include "defs.h" #if PDBFMTS_ENABLED -#include "coldsync/palm.h" -#include "coldsync/pdb.h" -# +#include "pdbfile.h" + #define MYNAME "Cetus" #define MYTYPE_WPT 0x43577074 /* CWpt */ #define MYTYPE_TRK 0x7374726d /* strm */ @@ -137,12 +136,10 @@ typedef struct cetus_track_point_s #define TRACK_POINT_SIZE sizeof(struct cetus_track_point_s) -static FILE *file_in; -static FILE *file_out; +static pdbfile *file_in, *file_out; static const char *out_fname; -static struct pdb *opdb; -static struct pdb_record *opdb_rec; static short_handle mkshort_wr_handle; +static int ct; static char *dbname = NULL; static char *appendicon = NULL; @@ -180,9 +177,9 @@ read_track_point(cetus_track_point_t *data, const time_t basetime) if (data->hdop != -1) wpt->hdop = (float) data->hdop / 10; i = be_read16(&data->speed); - if (i != 10000) wpt->speed = ((float) i / 10) * 0.514444; /* meters/second */ + if (i != 10000) WAYPT_SET(wpt, speed, KNOTS_TO_MPS((float) i / 10)); /* meters/second */ i = be_read16(&data->course); - if (i != 4000) wpt->course = (float) i / 10; + if (i != 4000) WAYPT_SET(wpt, course, (float) i / 10); switch(data->hour / 32) /* extract fix */ { @@ -201,9 +198,9 @@ read_track_point(cetus_track_point_t *data, const time_t basetime) static void -read_tracks(const struct pdb *pdb) +read_tracks(const pdbfile *pdb) { - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; int reclen, records, total, points, dropped; char descr[(2 * TRACK_POINT_SIZE) + 1]; char temp_descr[TRACK_POINT_SIZE + 1]; @@ -220,7 +217,7 @@ read_tracks(const struct pdb *pdb) dropped = 0; basetime = 0; - for (pdb_rec = pdb->rec_index.rec; pdb_rec != NULL; pdb_rec = pdb_rec->next) + for (pdb_rec = pdb->rec_list; pdb_rec; pdb_rec = pdb_rec->next) { int i, magic; char *c = (char *)pdb_rec->data; @@ -294,13 +291,13 @@ read_tracks(const struct pdb *pdb) } static void -read_waypts(const struct pdb *pdb) +read_waypts(const pdbfile *pdb) { struct cetus_wpt_s *rec; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; char *vdata; - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) + for(pdb_rec = pdb->rec_list; pdb_rec; pdb_rec = pdb_rec->next) { waypoint *wpt_tmp; int i; @@ -369,13 +366,13 @@ read_waypts(const struct pdb *pdb) static void rd_init(const char *fname) { - file_in = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); } static void rd_deinit(void) { - fclose(file_in); + pdb_close(file_in); if ( dbname ) { xfree(dbname); dbname = NULL; @@ -385,14 +382,15 @@ rd_deinit(void) static void wr_init(const char *fname) { - file_out = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); out_fname = fname; + ct = 0; } static void wr_deinit(void) { - fclose(file_out); + pdb_close(file_out); if ( dbname ) { xfree(dbname); dbname = NULL; @@ -402,11 +400,7 @@ wr_deinit(void) static void data_read(void) { - struct pdb *pdb; - - if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed\n"); - } + pdbfile *pdb = file_in; if (pdb->creator != MYCREATOR) fatal(MYNAME ": Not a Cetus file.\n"); @@ -420,7 +414,6 @@ data_read(void) read_waypts(pdb); break; } - free_pdb(pdb); } @@ -428,7 +421,6 @@ static void cetus_writewpt(const waypoint *wpt) { struct cetus_wpt_s *rec; - static int ct; struct tm *tm; char *vdata; char *desc_long; @@ -452,8 +444,7 @@ cetus_writewpt(const waypoint *wpt) rec->mon = 0xff; be_write16(&rec->year, 0xff); } - - be_write32(&rec->longitude, (unsigned int) (wpt->longitude * 10000000.0)); + be_write32(&rec->longitude, (unsigned int) (int) (wpt->longitude * 10000000.0)); be_write32(&rec->latitude, (unsigned int) (wpt->latitude * 10000000.0)); if ( wpt->altitude == unknown_alt ) { be_write32(&rec->elevation, -100000000); @@ -542,15 +533,8 @@ cetus_writewpt(const waypoint *wpt) } vdata += strlen( vdata ) + 1; - opdb_rec = new_Record (0, 2, ct++, (uword) (vdata-(char *)rec), (const ubyte *)rec); + pdb_write_rec(file_out, 0, 2, ct++, rec, (char *)vdata - (char *)rec); - if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record\n"); - } - - if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record\n"); - } xfree(rec); } @@ -581,22 +565,18 @@ data_write(void) setshort_length(mkshort_wr_handle, 15); setshort_whitespace_ok(mkshort_wr_handle, 0); - if (NULL == (opdb = new_pdb())) { - fatal (MYNAME ": new_pdb failed\n"); - } - if ( dbname ) { - strncpy( opdb->name, dbname, PDB_DBNAMELEN ); + strncpy( file_out->name, dbname, PDB_DBNAMELEN ); } else { - strncpy(opdb->name, out_fname, PDB_DBNAMELEN); + strncpy(file_out->name, out_fname, PDB_DBNAMELEN); } - opdb->name[PDB_DBNAMELEN-1] = 0; - opdb->attributes = PDB_ATTR_BACKUP; - opdb->ctime = opdb->mtime = current_time() + 2082844800U; - opdb->type = MYTYPE_WPT; /* CWpt */ - opdb->creator = MYCREATOR; /* cGPS */ - opdb->version = 1; + file_out->name[PDB_DBNAMELEN-1] = 0; + file_out->attr = PDB_FLAG_BACKUP; + file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->type = MYTYPE_WPT; /* CWpt */ + file_out->creator = MYCREATOR; /* cGPS */ + file_out->version = 1; /* * All this is to sort by waypoint names before going to Cetus. @@ -623,7 +603,6 @@ data_write(void) cetus_writewpt(htable[i].wpt); } - pdb_Write(opdb, fileno(file_out)); xfree(htable); mkshort_del_handle(&mkshort_wr_handle); } diff --git a/coldsync/Artistic b/coldsync/Artistic deleted file mode 100644 index 98299f957..000000000 --- a/coldsync/Artistic +++ /dev/null @@ -1,131 +0,0 @@ -$Id: Artistic,v 1.1 2002/08/16 15:54:46 robertl Exp $ - - - - The "Artistic License" - - Preamble - -The intent of this document is to state the conditions under which a -Package may be copied, such that the Copyright Holder maintains some -semblance of artistic control over the development of the package, -while giving the users of the package the right to use and distribute -the Package in a more-or-less customary fashion, plus the right to make -reasonable modifications. - -Definitions: - - "Package" refers to the collection of files distributed by the - Copyright Holder, and derivatives of that collection of files - created through textual modification. - - "Standard Version" refers to such a Package if it has not been - modified, or has been modified in accordance with the wishes - of the Copyright Holder as specified below. - - "Copyright Holder" is whoever is named in the copyright or - copyrights for the package. - - "You" is you, if you're thinking about copying or distributing - this Package. - - "Reasonable copying fee" is whatever you can justify on the - basis of media cost, duplication charges, time of people involved, - and so on. (You will not be required to justify it to the - Copyright Holder, but only to the computing community at large - as a market that must bear the fee.) - - "Freely Available" means that no fee is charged for the item - itself, though there may be fees involved in handling the item. - It also means that recipients of the item may redistribute it - under the same conditions they received it. - -1. You may make and give away verbatim copies of the source form of the -Standard Version of this Package without restriction, provided that you -duplicate all of the original copyright notices and associated disclaimers. - -2. You may apply bug fixes, portability fixes and other modifications -derived from the Public Domain or from the Copyright Holder. A Package -modified in such a way shall still be considered the Standard Version. - -3. You may otherwise modify your copy of this Package in any way, provided -that you insert a prominent notice in each changed file stating how and -when you changed that file, and provided that you do at least ONE of the -following: - - a) place your modifications in the Public Domain or otherwise make them - Freely Available, such as by posting said modifications to Usenet or - an equivalent medium, or placing the modifications on a major archive - site such as uunet.uu.net, or by allowing the Copyright Holder to include - your modifications in the Standard Version of the Package. - - b) use the modified Package only within your corporation or organization. - - c) rename any non-standard executables so the names do not conflict - with standard executables, which must also be provided, and provide - a separate manual page for each non-standard executable that clearly - documents how it differs from the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - -4. You may distribute the programs of this Package in object code or -executable form, provided that you do at least ONE of the following: - - a) distribute a Standard Version of the executables and library files, - together with instructions (in the manual page or equivalent) on where - to get the Standard Version. - - b) accompany the distribution with the machine-readable source of - the Package with your modifications. - - c) give non-standard executables non-standard names, and clearly - document the differences in manual pages (or equivalent), together - with instructions on where to get the Standard Version. - - d) make other distribution arrangements with the Copyright Holder. - -5. You may charge a reasonable copying fee for any distribution of this -Package. You may charge any fee you choose for support of this -Package. You may not charge a fee for this Package itself. However, -you may distribute this Package in aggregate with other (possibly -commercial) programs as part of a larger (possibly commercial) software -distribution provided that you do not advertise this Package as a -product of your own. You may embed this Package's interpreter within -an executable of yours (by linking); this shall be construed as a mere -form of aggregation, provided that the complete Standard Version of the -interpreter is so embedded. - -6. The scripts and library files supplied as input to or produced as -output from the programs of this Package do not automatically fall -under the copyright of this Package, but belong to whoever generated -them, and may be sold commercially, and may be aggregated with this -Package. If such scripts or library files are aggregated with this -Package via the so-called "undump" or "unexec" methods of producing a -binary executable image, then distribution of such an image shall -neither be construed as a distribution of this Package nor shall it -fall under the restrictions of Paragraphs 3 and 4, provided that you do -not represent such an executable image as a Standard Version of this -Package. - -7. C subroutines (or comparably compiled subroutines in other -languages) supplied by you and linked into this Package in order to -emulate subroutines and variables of the language defined by this -Package shall not be considered part of this Package, but are the -equivalent of input as in Paragraph 6, provided these subroutines do -not change the language in any way that would cause it to fail the -regression tests for the language. - -8. Aggregation of this Package with a commercial distribution is always -permitted provided that the use of this Package is embedded; that is, -when no overt attempt is made to make this Package's interfaces visible -to the end user of the commercial distribution. Such use shall not be -construed as a distribution of this Package. - -9. The name of the Copyright Holder may not be used to endorse or promote -products derived from this software without specific prior written permission. - -10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - - The End diff --git a/coldsync/Makefile b/coldsync/Makefile deleted file mode 100644 index e69de29bb..000000000 diff --git a/coldsync/Makefile.in b/coldsync/Makefile.in deleted file mode 100644 index e69de29bb..000000000 diff --git a/coldsync/README b/coldsync/README deleted file mode 100644 index 0d97b54aa..000000000 --- a/coldsync/README +++ /dev/null @@ -1,211 +0,0 @@ - This is ColdSync, a tool for synchronizing data between Palm -devices and Unix workstations. - - Copyright (C) 1999-2001, Andrew Arensburger. - - The latest version of this package is available at - http://www.ooblick.com/software/coldsync/ - - This package is distributable under the terms of the Artistic -License. You should have received a file called "Artistic", which -specifies the terms under which this package may be distributed and -modified. - The Artistic License is taken from the Perl 5.005_03 -distribution, so some of the text is specific to Perl and does not -apply to ColdSync. I hope to address this in a future release. - - This product includes software developed by the University of -California, Berkeley and its contributors. - - This product includes software developed by the Apache Group -for use in the Apache HTTP server project (http://www.apache.org/). - (Actually, the Apache code in question was written by Panos -Tsirigotis. See comments in "src/ap_snprintf.c".) - - ---------------------------------------- - -* WHAT IS COLDSYNC? - - ColdSync is a tool for synchronizing data between Palm -computing devices (such as the PalmPilot, PalmPilot Pro, Palm V, -QualComm PDQ, Handspring Visor and so forth), and a Unix workstation. - ColdSync can back up and restore the state of a Palm, as well -as synchronize its data, which is sort of like a two-way rdist (see -below). In future versions, it will be possible to do more interesting -things with this data. - -* WHAT YOU'LL NEED - - - A POSIX-compliant operating system, preferably some flavor - of Unix - - An ANSI C compiler - - An ANSI C++ compiler - - Perl 5.005_03 or later (though earlier versions might work) - -* BUILDING AND INSTALLING COLDSYNC - - If you've built GNU software before, this should be familiar -territory. You should be able to just - - ./configure - make - make install - -Full details are provided in the "INSTALL" file. - -* WHAT IS SYNCHRONIZING? - - Synchronizing, also referred to as "syncing" refers to the -process of examining two databases (everything on the Palm is a -database) to see how they differ, and updating them so that they are -identical. - Syncing is different from just overwriting one database with -the other. For instance, if you add an entry for "Aunt Mabel" in your -Palm's address book, and an entry for "Uncle Bob" on your desktop -machine, then you don't want to just copy the address book from the -Palm to the desktop or vice-versa: that would delete one of the -entries that you just created. When you sync with ColdSync, you'll -wind up with both entries, on both the Palm and the desktop. - - Another difference between synchronizing and blind copying -lies in the fact that PalmOS has facilities to support syncing. If you -have 2000 entries in your Palm address book and want to copy them to -the desktop, it'll take a rather long time to copy them over a -relatively slow serial connection. When it syncs, ColdSync copies only -those records that have changed. - - ColdSync tries to be very cautious when it syncs, and not -delete any information unless it is sure that that is the right thing -to do. Its attitude is that it's better to err on the side of caution, -and maybe make you delete something twice, than it is to delete some -crucial bit of information. - -* SECURITY CONSIDERATIONS - - ColdSync is not secure. Period. - I have tried to pay due attention to security considerations, -but the sync process itself is inherently insecure. When ColdSync, -running on a workstation, receives a connection from a Palm, it has no -reliable way of knowing that the Palm on the other end is in fact the -one that it claims to be. - Likewise, when a Palm syncs with a workstation (whether that -workstation is using ColdSync or Palm's own HotSync), it has no -reliable way of knowing that the workstation is the one that it claims -to be. - PalmOS allows you to mark records as "private." This doesn't -mean a thing when you sync: the private and non-private records are -treated equally. In particular, anyone who has physical access to your -Palm can download your private records. - - There may be a Palm utility out there that will encrypt each -record in a database before a sync, but I don't know of any such -utility. - -* INTERNATIONALIZATION - - ColdSync includes some internationalization (i18n) support. It -is believed to work on all platforms with a Uniforum-compliant libintl -(gettext()). ColdSync does not work with XPG i18n (catgets() etc.). - However, you need GNU xgettext to compile the message catalog -("i18n/messages.po") from the source files. - - ---------------------------------------- - -COMPATIBILITY NOTES - -* ColdSync 2.2.4 - -FreeBSD: - This package was developed under FreeBSD 3.x/4.x, and compiles - cleanly with no modification under 4.2-RELEASE. - - On newer versions of FreeBSD (4.0 and beyond), it's possible - to communicate with the Handspring Visor using its USB - interface. Configure a listen type of "usb" rather than - "serial", and use device /dev/ugen0. - -Redhat Linux 6.2 (also Debian, and probably others): - (as of ColdSync v1.6.6-20010130) - Compiles cleanly with no modifications. Runs fine. - - The Linux serial device driver appears to drop characters at - random. As a result, you may see a lot of - - ##### Got an unexpected data packet. Sending an ACK to shut it up. - - messages. - -Solaris 2.7: - (as of v2.2.4) - There are still some problems with ColdSync's IPv6 code under - Solaris 2.6 and later. You'll need to use - ./configure --without-ipv6 - - (as of v2.2.0-20010805) - Compiles with Sun Forte 6U1. - - ColdSync is known not to work with Sun's i18n utilities. - ColdSync should detect this, and disable i18n. - -Digital Unix 4.0: - (as of ColdSync v2.4.4-20011113) - DEC's linker chokes on the overly-long identifiers produced by - the STL. GNU ld might work. - - (as of ColdSync v1.6.6-20010130) - Compiles with gcc 2.7.2. Compilation prints several warnings; - they appear to be benign: - - PConnection_serial.c:444: warning: implicit declaration of function `cfmakeraw' - PConnection_net.c:281: warning: passing arg 6 of `_Erecvfrom' from incompatiblepointer type - PConnection_net.c:674: warning: passing arg 6 of `_Erecvfrom' from incompatiblepointer type - PConnection_net.c:872: warning: passing arg 3 of `_Eaccept' from incompatible pointer type - config.c:964: warning: overflow in implicit constant conversion - GenericConduit.cc:82: warning: unused parameter `const struct conduit_block * block' - - If you are using DEC's C compiler, I suggest the following - compiler flags: - -std1 -msg_enable level3 - - -AIX 4.1: - (as of ColdSync v1.1.2) - Compiles with gcc 2.7.2, but when linking, complains that: - - ld: 0711-224 WARNING: Duplicate symbol: _IO_cleanup_registration_needed - ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. - - This may be a problem with the installation, though (the same - thing happens when compiling "Hello, world"). - - I've only compiled it. I don't know whether it actually runs. - -If you have any updated information, please send it in to the -maintainer (arensb@ooblick.com). My testing pool isn't as large as it -once was. - -Windows NT: - (as of ColdSync 1.4.5) - To the best of my knowledge, ColdSync compiles and runs under - Windows NT with the Cygwin tools. - - However, ColdSync was written as a Unix tool. Windows users - have the HotSync desktop tools from Palm, which work quite - well. If ColdSync works under Windows, that's wonderful, but - I'm not going to let Windows compatibility get in the way of - Unix development. - -MacOS X: - (as of ColdSync 1.4.6) - - According to one correspondent, ColdSync compiles and runs - with no problems under MacOS X. - The serial port should be /dev/ttyd.printer . - - ---------------------------------------- - -BUGS: - If you create a Memo record, delete it without leaving the -editor, and check the "Save archive copy on PC" box, it will be -archived, but the archived record may contain trailing garbage. - This is due to a bug in PalmOS (as of 3.0). diff --git a/coldsync/README.gpsbabel b/coldsync/README.gpsbabel deleted file mode 100644 index 6315fcad4..000000000 --- a/coldsync/README.gpsbabel +++ /dev/null @@ -1,10 +0,0 @@ -This directory is a subset of coldsync-2.2.5. GPSbabel needs very -limited set of that functionality to read and write Palm/OS files. -I was faced with either reimplementing it (and I DON'T want to -become a Palm/OS expert) or cribbing the code. Since it's all under -Artistic license, I took libpdb and the includes, whacked out the most -horribly non-portable pieces, jacked in a constant config.h, and pointed -the makefiles to it. - -Thanx to the ColdSync guys for figuring this stuff out! - diff --git a/coldsync/cs-config.h b/coldsync/cs-config.h deleted file mode 100644 index 69eadd99c..000000000 --- a/coldsync/cs-config.h +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Assume we're on a conformant ISO C platform. - */ - - -#define STDC_HEADERS 1 -#define _(str) str -#define inline diff --git a/coldsync/palm.h b/coldsync/palm.h deleted file mode 100644 index 2b111d532..000000000 --- a/coldsync/palm.h +++ /dev/null @@ -1,55 +0,0 @@ -/* palm.h - * Definitions of various types that PalmOS likes to use. - * - * Copyright (C) 2001, Andrew Arensburger. - * You may distribute this file under the terms of the Artistic - * License, as specified in the README file. - * - * $Id: palm.h,v 1.2 2005/10/24 18:26:30 robertl Exp $ - */ -#ifndef _palm_h_ -#define _palm_h_ - -#include "../gbtypes.h" - -/* Convenience types */ -typedef signed char byte; /* Signed 8-bit quantity */ -typedef unsigned char ubyte; /* Unsigned 8-bit quantity */ -typedef gbint16 word; /* Signed 16-bit quantity */ -typedef gbuint16 uword; /* Unsigned 16-bit quantity */ -typedef gbint32 dword; /* Signed 32-bit quantity */ -typedef gbuint32 udword; /* Unsigned 32-bit quantity */ - -typedef udword chunkID; /* Those IDs made up of four - * characters stuck together into a - * 32-bit quantity. - */ - -/* Explicitly define the sizes of types. Can't depend on the host's types - * having the same size as the Palm. For instance, Alphas are 64-bit - * machines, so 'unsigned long' is 8 bytes, whereas 'udword' is only 4 - * bytes. - */ -#define SIZEOF_BYTE 1 -#define SIZEOF_UBYTE 1 -#define SIZEOF_WORD 2 -#define SIZEOF_UWORD 2 -#define SIZEOF_DWORD 4 -#define SIZEOF_UDWORD 4 - -/* MAKE_CHUNKID - * A convenience macro to make a chunkID out of four characters. - */ -#define MAKE_CHUNKID(a,b,c,d) \ - (((a) << 24) | \ - ((b) << 16) | \ - ((c) << 8) | \ - (d)) - -/* XXX - There ought to be something to make sure that the sizes and - * signedness above are true. - */ - -typedef enum { False = 0, True = 1 } Bool; - -#endif /* _palm_h_ */ diff --git a/coldsync/pconn/util.h b/coldsync/pconn/util.h deleted file mode 100644 index 17d3c59d0..000000000 --- a/coldsync/pconn/util.h +++ /dev/null @@ -1,60 +0,0 @@ -/* util.h - * Misc. useful stuff. - * - * Copyright (C) 1999-2000, Andrew Arensburger. - * You may distribute this file under the terms of the Artistic - * License, as specified in the README file. - * - * $Id: util.h,v 1.2 2002/08/24 03:01:31 robertl Exp $ - */ -#ifndef _util_h_ -#define _util_h_ - -#include -#include -#include "palm.h" - -/* XXX - The functions declared INLINE, below, really ought to be inline - * functions. I'm not sure how to do this portably, though. - */ -#ifdef __GNUC__ -# define INLINE __inline__ -#else -# define INLINE -#endif /* __GNUC__ */ - -/* Functions for reading a value from an array of ubytes */ -extern INLINE ubyte peek_ubyte(const ubyte *buf); -extern INLINE uword peek_uword(const ubyte *buf); -extern INLINE udword peek_udword(const ubyte *buf); - -/* Functions for extracting values from an array of ubytes */ -extern INLINE ubyte get_ubyte(const ubyte **buf); -extern INLINE uword get_uword(const ubyte **buf); -extern INLINE udword get_udword(const ubyte **buf); - -/* Functions for writing values to an array of ubytes */ -extern INLINE void put_ubyte(ubyte **buf, const ubyte value); -extern INLINE void put_uword(ubyte **buf, const uword value); -extern INLINE void put_udword(ubyte **buf, const udword value); - -#if TIME -/* Functions for converting between DLP's time format and Unix's - * time_ts and the time_t-with-offset that the rest of the Palm stuff - * uses. - */ -extern time_t time_dlp2time_t(const struct dlp_time *dlpt); -extern udword time_dlp2palmtime(const struct dlp_time *dlpt); -extern void time_time_t2dlp(const time_t t, struct dlp_time *dlpt); -extern void time_palmtime2dlp(const udword palmt, struct dlp_time *dlpt); - -extern void debug_dump(FILE *outfile, const char *prefix, - const ubyte *buf, const udword len); -#endif -#endif /* _util_h_ */ - - /* This is for Emacs's benefit: - * Local Variables: *** - * fill-column: 75 *** - * End: *** - */ diff --git a/coldsync/pdb.c b/coldsync/pdb.c deleted file mode 100644 index 161efc64c..000000000 --- a/coldsync/pdb.c +++ /dev/null @@ -1,2038 +0,0 @@ -/* pdb.c - * - * Functions for dealing with Palm databases and such. - * - * Copyright (C) 1999-2001, Andrew Arensburger. - * You may distribute this file under the terms of the Artistic - * License, as specified in the README file. - * - * $Id: pdb.c,v 1.12 2006/07/13 03:27:53 robertl Exp $ - */ -/* XXX - The way zero-length records are handled is a bit of a kludge. They - * shouldn't normally exist, with the exception of expunged records. But, - * of course, a malformed conduit or something can create them. - * The half-assed way they're handled here is to a) not upload zero-length - * records to the Palm, b) warn the user if they're written to a file, c) - * provide a utility (in the p5-Palm package) to delete zero-length - * records. - */ -/* XXX - This is a library. It shouldn't print error messages. - * Add 'int pdb_errno'; define error numbers and error messages that go - * with them. - * Debugging messages should go to 'FILE *pdb_logfile'. - */ -#include "config.h" -#if PDBFMTS_ENABLED - -#include "cs-config.h" -#include -#include /* For open() */ -#include -/* - * Unistd.h (indeed, read, write, and lseek) are not part of ISO C. - * Systems may not have unistd.h. While the below is tacky, Windows - * is the only system that we care about that has lseek and friends - * but doesn't have it prototyped. Systems with 64-bit file I/O but - * based on LP64 model (i.e. OS/X) _require_ the prototype for lseek. - */ -#if defined (__WIN32__) -#include -#define lseek _lseek -#define write _write -#define read _read -#define close _close -#else -#include -#endif -#include -#include - -#if STDC_HEADERS -# include /* For strncat(), memcpy() et al. */ -#else /* STDC_HEADERS */ -# ifndef HAVE_STRCHR -# define strchr index -# define strrchr rindex -# endif /* HAVE_STRCHR */ -# ifndef HAVE_MEMCPY -# define memcpy(d,s,n) bcopy ((s), (d), (n)) -# define memmove(d,s,n) bcopy ((s), (d), (n)) -# endif /* HAVE_MEMCPY */ -#endif /* STDC_HEADERS */ - -/* XXX - Is this right? Should this be in the "else" clause, above? */ -#if HAVE_STRINGS_H -# include /* For bzero() */ -#endif /* HAVE_STRINGS_H */ - -#if HAVE_LIBINTL_H -# include /* For i18n */ -#endif /* HAVE_LIBINTL_H */ - -#include -#include "pdb.h" - -/* XXX - The functions declared INLINE, below, really ought to be inline - * functions. I'm not sure how to do this portably, though. - */ -#ifdef __GNUC__ -# define INLINE __inline__ -#else -# define INLINE -#endif /* __GNUC__ */ - -/* Functions for extracting values from an array of ubytes */ -extern INLINE ubyte get_ubyte(const ubyte **buf); -extern INLINE uword get_uword(const ubyte **buf); -extern INLINE udword get_udword(const ubyte **buf); - -/* Functions for writing values to an array of ubytes */ -extern INLINE void put_ubyte(ubyte **buf, const ubyte value); -extern INLINE void put_uword(ubyte **buf, const uword value); -extern INLINE void put_udword(ubyte **buf, const udword value); -extern void debug_dump(FILE *outfile, const char *prefix, - const ubyte *buf, const udword len); - -int pdb_trace = 0; /* Debugging level for PDB stuff */ -#define PDB_TRACE(n) if (pdb_trace >= (n)) - -/* Helper functions */ -static uword get_file_length(int fd); -int pdb_LoadHeader(int fd, struct pdb *db); - /* pdb_LoadHeader() is visible to other files */ -static int pdb_LoadRecListHeader(int fd, struct pdb *db); -static int pdb_LoadRsrcIndex(int fd, struct pdb *db); -static int pdb_LoadRecIndex(int fd, struct pdb *db); -static int pdb_LoadAppBlock(int fd, struct pdb *db); -static int pdb_LoadSortBlock(int fd, struct pdb *db); -static int pdb_LoadResources(int fd, struct pdb *db); -static int pdb_LoadRecords(int fd, struct pdb *db); - -/* merge_attributes - * Takes a record's flags and category, and merges them into a single byte, - * with the flags in the top nybble and the category in the bottom one - */ -static inline ubyte -merge_attributes(const ubyte flags, - const ubyte category) -{ - /* The PDB_REC_ARCHIVED flag is troublesome, since it overlaps the - * category field. The idea here is that if the record was deleted, - * then it doesn't have a category anymore, so the category part - * gets set to 0. - */ - if ((flags & PDB_REC_DELETED) == 0) - return (flags & 0xf0) | - (category & 0x0f); - else - return (flags & 0xf8); -} - -/* split_attributes - * The converse of merge_attributes(). Takes the combined field attributes - * and writes its contents to *flags and *category, using the same rules as - * merge_attributes(), above. - */ -static inline void -split_attributes(const ubyte attributes, - ubyte *flags, - ubyte *category) -{ - if ((attributes & PDB_REC_DELETED) == 0) - { - *flags = (attributes & 0xf0); - *category = (attributes & 0x0f); - } else { - *flags = (attributes & 0xf8); - *category = 0; - } - PDB_TRACE(6) - fprintf(stderr, "split 0x%02x into 0x%02x, 0x%02x\n", - attributes, *flags, *category); -} - -/* new_pdb - * struct pdb constructor. - */ -struct pdb * -new_pdb() -{ - struct pdb *retval; - - /* Allocate the new pdb */ - if ((retval = (struct pdb *) malloc(sizeof(struct pdb))) == NULL) - /* Out of memory */ - return NULL; - - /* Write zeros all over it, just for safety */ - memset((void *) retval, 0, sizeof(struct pdb)); - - return retval; -} - -/* pdb_FreeRecord - * Free a previously-allocated 'pdb_record'. This function wouldn't really - * be necessary, except that pdb_CopyRecord() returns a 'pdb_record'. - */ -void -pdb_FreeRecord(struct pdb_record *rec) -{ - if (rec->data != NULL) - free(rec->data); - free(rec); -} - -/* pdb_FreeResource - * Free a previously-allocated 'pdb_resource'. This function wouldn't - * really be necessary, except that pdb_CopyResource() returns a - * 'pdb_resource'. - */ -void -pdb_FreeResource(struct pdb_resource *rsrc) -{ - if (rsrc->data != NULL) - free(rsrc->data); - free(rsrc); -} - -/* free_pdb - * Cleanly free a struct pdb, and all of its subparts (destructor). - */ -void -free_pdb(struct pdb *db) -{ - PDB_TRACE(7) - fprintf(stderr, "Inside free_pdb(%p)\n", (void *) db); - - if (db == NULL) - /* Trivial case */ - return; - - /* Free the array of records/resources */ - if (IS_RSRC_DB(db)) - { - /* It's a resource database */ - struct pdb_resource *rsrc; - struct pdb_resource *next; - - PDB_TRACE(8) - fprintf(stderr, "Freeing resource list\n"); - - /* Walk the linked list, freeing as we go along */ - for (rsrc = db->rec_index.rsrc; - rsrc != NULL; - rsrc = next) - { - next = rsrc->next; /* Remember the next - * element on the list. We - * won't have a chance to - * look it up after this - * one has been free()d. - */ - - /* Free this element */ - pdb_FreeResource(rsrc); - } - } else { - /* It's a record database */ - struct pdb_record *rec; - struct pdb_record *next; - - PDB_TRACE(8) - fprintf(stderr, "Freeing record list\n"); - - /* Walk the linked list, freeing as we go along */ - for (rec = db->rec_index.rec; - rec != NULL; - rec = next) - { - next = rec->next; /* Remember the next - * element on the list. We - * won't have a chance to - * look it up after this - * one has been free()d. - */ - - /* Free this element */ - pdb_FreeRecord(rec); - } - } - - /* Free the sort block */ - if (db->sortinfo != NULL) - free(db->sortinfo); - - /* Free the app info block */ - if (db->appinfo != NULL) - free(db->appinfo); - - free(db); -} - -/* pdb_Read - * Read a PDB from the file descriptor 'fd'. This must already have been - * opened for reading and/or writing. - * - * Note: this function does not to any locking. The caller is responsible - * for that. - */ -struct pdb * -pdb_Read(int fd) -{ - int err; - struct pdb *retval; - - /* Create a new pdb to return */ - if ((retval = new_pdb()) == NULL) - { - return NULL; - } - - /* Find out how long the file is */ - retval->file_size = get_file_length(fd); - if (retval->file_size == ~0) - { - /* The file isn't seekable */ - fprintf(stderr, _("File isn't seekable.\n")); - free_pdb(retval); - return NULL; - } - - /* Load the header */ - if ((err = pdb_LoadHeader(fd, retval)) < 0) - { - fprintf(stderr, _("Can't load header.\n")); - free_pdb(retval); - return NULL; - } - - /* Load the record list header */ - if ((err = pdb_LoadRecListHeader(fd, retval)) < 0) - { - fprintf(stderr, _("Can't load record list header for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - - /* Read the record/resource list */ - if (IS_RSRC_DB(retval)) - { - /* Read the resource index */ - if ((err = pdb_LoadRsrcIndex(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read resource index for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - } else { - /* Read the record index */ - if ((err = pdb_LoadRecIndex(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read record index for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - } - - /* In most PDBs, there are two NUL bytes here. They are allowed by - * the spec, but not mandated, and some PDBs don't have them. We'll - * ignore them for now, and have the appropriate pdb_Load*() - * function lseek() to the proper position. - */ - - /* Load the AppInfo block, if any */ - if ((err = pdb_LoadAppBlock(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read AppInfo block for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - - /* Load the sort block, if any */ - if ((err = pdb_LoadSortBlock(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read sort block for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - - /* Load the records themselves */ - if (IS_RSRC_DB(retval)) - { - /* Read the resources */ - if ((err = pdb_LoadResources(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read resources for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - } else { - /* Read the records */ - if ((err = pdb_LoadRecords(fd, retval)) < 0) - { - fprintf(stderr, _("Can't read records for " - "\"%.*s\".\n"), - PDB_DBNAMELEN, retval->name); - free_pdb(retval); - return NULL; - } - } - - return retval; /* Success */ -} - -/* pdb_Write - * Write 'db' to the file descriptor 'fd'. This must already have been - * opened for writing. - * - * Note that while you can open the backup file for reading and writing, - * read from it with pdb_Read() and save it with pdb_Write(), this is not - * recommended: if anything should go wrong at the wrong time (e.g., the - * disk fills up just as you're about to write the database back to disk), - * you will lose the entire backup. - * A better approach is to use a staging file: read from the backup file, - * write to a temporary file, then use rename() to move the temporary file - * onto the real one. Alternately, you can copy the original file to a - * temporary one, then open the temporary for both reading and writing. - * This might have some advantages, in that it allows you to lock a single - * file for the duration of the sync. - * - * Note: this function does not lock the file. The caller is responsible - * for that. - */ -int -pdb_Write(const struct pdb *db, - int fd) -{ - static ubyte header_buf[PDB_HEADER_LEN]; - /* Buffer for writing database header */ - static ubyte rlheader_buf[PDB_RECORDLIST_LEN]; - /* Buffer for writing the record list header */ - static ubyte nul_buf[2]; - /* Buffer for writing the two useless NULs */ - ubyte *wptr; /* Pointer into buffers, for writing */ - udword offset; /* The next offset we're interested in */ - - /* Initialize 'offset': the next variable-sized item will go after - * the header, after the index header, after the index, after the - * two useless NULs. - */ - offset = PDB_HEADER_LEN + PDB_RECORDLIST_LEN; - if (IS_RSRC_DB(db)) - offset += db->numrecs * PDB_RESOURCEIX_LEN; - else - offset += db->numrecs * PDB_RECORDIX_LEN; - offset += 2; /* Those two useless NUL bytes */ - - /** Write the database header **/ - - /* Construct the header in 'header_buf' */ - wptr = header_buf; - memcpy(wptr, db->name, PDB_DBNAMELEN); - wptr += PDB_DBNAMELEN; - put_uword(&wptr, (uword) (db->attributes & ~PDB_ATTR_OPEN)); - /* Clear the 'open' flag before writing */ - put_uword(&wptr, db->version); - put_udword(&wptr, db->ctime); - put_udword(&wptr, db->mtime); - put_udword(&wptr, db->baktime); - put_udword(&wptr, db->modnum); - if (db->appinfo == NULL) /* Write the AppInfo block, if any */ - /* This database doesn't have an AppInfo block */ - put_udword(&wptr, 0L); - else { - /* This database has an AppInfo block */ - put_udword(&wptr, offset); - offset += db->appinfo_len; - } - if (db->sortinfo == NULL) /* Write the sort block, if any */ - /* This database doesn't have a sort block */ - put_udword(&wptr, 0L); - else { - put_udword(&wptr, offset); - offset += db->sortinfo_len; - } - put_udword(&wptr, db->type); - put_udword(&wptr, db->creator); - put_udword(&wptr, db->uniqueIDseed); - - /* Write the database header */ - if (write(fd, header_buf, PDB_HEADER_LEN) != PDB_HEADER_LEN) - { - fprintf(stderr, _("%s: can't write database header for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - close(fd); - return -1; - } - - /** Write the record/resource index header **/ - /* Construct the record list header */ - wptr = rlheader_buf; - put_udword(&wptr, 0L); /* nextID */ - /* XXX - What is this? Should this be something - * other than 0? */ - put_uword(&wptr, db->numrecs); - - /* Write the record list header */ - if (write(fd, rlheader_buf, PDB_RECORDLIST_LEN) != PDB_RECORDLIST_LEN) - { - fprintf(stderr, _("%s: can't write record list header for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - - /* Write the record/resource index */ - if (IS_RSRC_DB(db)) - { - /* It's a resource database */ - struct pdb_resource *rsrc; /* Current resource */ - - /* Go through the list of resources, writing each one */ - for (rsrc = db->rec_index.rsrc; - rsrc != NULL; - rsrc = rsrc->next) - { - static ubyte rsrcbuf[PDB_RESOURCEIX_LEN]; - /* Buffer to hold the resource - * index entry. - */ - - /* Construct the resource index entry */ - wptr = rsrcbuf; - put_udword(&wptr, rsrc->type); - put_uword(&wptr, rsrc->id); - put_udword(&wptr, offset); - - /* Write the resource index entry */ - if (write(fd, rsrcbuf, PDB_RESOURCEIX_LEN) != - PDB_RESOURCEIX_LEN) - { - fprintf(stderr, _("%s: Can't write resource " - "index entry for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - - /* Bump 'offset' up to point to the offset of the - * next variable-sized thing in the file. - */ - offset += rsrc->data_len; - } - } else { - /* It's a record database */ - struct pdb_record *rec; /* Current record */ - - /* Go through the list of records, writing each one */ - for (rec = db->rec_index.rec; rec != NULL; rec = rec->next) - { - static ubyte recbuf[PDB_RECORDIX_LEN]; - /* Buffer to hold the record index - * entry. - */ - - /* Construct the record index entry */ - wptr = recbuf; - - /* Sanity check */ - if (rec->data_len == 0) - { - fprintf(stderr, - _("\"%.*s\" record 0x%08lx has " - "length 0.\n"), - PDB_DBNAMELEN, db->name, - (unsigned long) rec->id); - } - - put_udword(&wptr, offset); - put_ubyte(&wptr, merge_attributes( - rec->flags, - rec->category)); - put_ubyte(&wptr, (char) ((rec->id >> 16) & 0xff)); - put_ubyte(&wptr, (char) ((rec->id >> 8) & 0xff)); - put_ubyte(&wptr, (char) (rec->id & 0xff)); - - /* Write the resource index entry */ - if (write(fd, recbuf, PDB_RECORDIX_LEN) != - PDB_RECORDIX_LEN) - { - fprintf(stderr, _("%s: Can't write record " - "index entry for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - - /* Bump 'offset' up to point to the offset of the - * next variable-sized thing in the file. - */ - offset += rec->data_len; - } - } - - /* Write the two useless NUL bytes */ - nul_buf[0] = nul_buf[1] = '\0'; - if (write(fd, nul_buf, 2) != 2) - { - fprintf(stderr, _("%s: Can't write the two useless NULs to " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - - /* Write the AppInfo block, if any */ - if (db->appinfo != NULL) - { - if (write(fd, db->appinfo, db->appinfo_len) != - db->appinfo_len) - { - fprintf(stderr, _("%s: Can't write AppInfo block for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - } - - /* Write the sort block, if any */ - if (db->sortinfo != NULL) - { - if (write(fd, db->sortinfo, db->sortinfo_len) != - db->sortinfo_len) - { - fprintf(stderr, _("%s: Can't write sort block for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - } - - /* Write the record/resource data */ - if (IS_RSRC_DB(db)) - { - /* It's a resource database */ - struct pdb_resource *rsrc; - - /* Go through the list of resources, writing each one's - * data. - */ - for (rsrc = db->rec_index.rsrc; - rsrc != NULL; - rsrc = rsrc->next) - { - /* Write the data */ - if (write(fd, rsrc->data, rsrc->data_len) != - rsrc->data_len) - { - fprintf(stderr, _("%s: Can't write resource " - "data for \"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - } - } else { - /* It's a record database */ - struct pdb_record *rec; - - /* Go through the list of records, writing each one's data. */ - for (rec = db->rec_index.rec; rec != NULL; rec = rec->next) - { - /* Write the data */ - if (write(fd, rec->data, rec->data_len) != - rec->data_len) - { - fprintf(stderr, - _("%s: Can't write record data for " - "\"%.*s\".\n"), - "pdb_Write", - PDB_DBNAMELEN, db->name); - perror("write"); - return -1; - } - } - } - - return 0; /* Success */ -} - -#if 0 -/* pdb_FindRecordByID - * Find the record in 'db' whose ID is 'id'. Return a pointer to it. If no - * such record exists, or in case of error, returns NULL. - */ -struct pdb_record * -pdb_FindRecordByID( - const struct pdb *db, - const udword id) -{ - struct pdb_record *rec; - - /* Walk the list of records, comparing IDs */ - for (rec = db->rec_index.rec; rec != NULL; rec = rec->next) - { - if (rec->id == id) - return rec; - } - - return NULL; /* Couldn't find it */ -} - -/* pdb_FindRecordByIndex - * Find the 'index'th record in 'db', and return a pointer to it. If no - * such record exists, or in case of error, return NULL. - */ -struct pdb_record * -pdb_FindRecordByIndex( - const struct pdb *db, /* Database to look in */ - const uword index) /* Index of the record to look for */ -{ - struct pdb_record *rec; - int i; - - /* Walk the list, decrementing the count as we go along. If it - * reaches 0, we've found the record. - */ - rec = db->rec_index.rec; - for (i = index; i > 0; i--) - { - if (rec == NULL) - /* Oops! We've fallen off the end of the list */ - return NULL; - rec = rec->next; - } - - return rec; /* Success */ -} - -/* pdb_NextRecord - * Find the next record after 'rec' in 'db', and return a pointer to it. If - * 'rec' is the last record in the list, return NULL. - */ -struct pdb_record * -pdb_NextRecord(const struct pdb *db, /* Database to look in */ - const struct pdb_record *rec) - /* Return 'rec's successor */ -{ - return rec->next; -} - -/* pdb_DeleteRecordByID - * Find the record whose unique ID is 'id' and delete it from 'db'. If the - * record isn't found, well, that's okay; we wanted to delete it anyway. - * Returns 0 if successful, -1 in case of error. - */ -int -pdb_DeleteRecordByID( - struct pdb *db, - const udword id) -{ - struct pdb_record *rec; /* Record we're looking at */ - struct pdb_record *last; /* Last record we saw */ - - if (IS_RSRC_DB(db)) - /* This only works with record databases */ - return -1; - - /* Look through the list of records */ - last = NULL; /* Haven't seen any records yet */ - for (rec = db->rec_index.rec; rec != NULL; rec = rec->next) - { - /* See if the ID matches */ - if (rec->id == id) - { - /* Found it */ - - /* XXX - Presumably better to use pdb_FreeRecord() */ - /* Free 'rec's data */ - if (rec->data != NULL) - free(rec->data); - - /* Cut 'rec' out of the list. The first element of - * the list is a special case. - */ - if (last == NULL) - db->rec_index.rec = rec->next; - else - last->next = rec->next; - - free(rec); /* Free it */ - db->numrecs--; /* Decrement record count */ - - return 0; /* Success */ - } - - last = rec; /* Remember what we just saw */ - } - - /* Couldn't find it. Oh, well. Call it a success anyway. */ - return 0; -} -#endif - -/* pdb_AppendRecord - * Append a new record to 'db's record list. 'newrec' is not copied, so it - * is important that the caller not free it afterwards. - */ -/* XXX - Ought to make sure that the ID is unique */ -int -pdb_AppendRecord(struct pdb *db, - struct pdb_record *newrec) -{ - struct pdb_record *rec; - - /* Sanity check */ - if (IS_RSRC_DB(db)) - /* This only works with record databases */ - return -1; - - /* Check to see if the list is empty */ - if (db->rec_index.rec == NULL) - { - db->rec_index.rec = newrec; - newrec->next = NULL; - - db->numrecs++; /* Bump record counter */ - - return 0; /* Success */ - } - - /* Walk the list to find its end */ - for (rec = db->rec_index.rec; rec->next != NULL; rec = rec->next) - ; - rec->next = newrec; - newrec->next = NULL; - - db->numrecs++; /* Bump record counter */ - - return 0; /* Success */ -} - -/* pdb_AppendResource - * Append a new resource to 'db's resource list. 'newrsrc' is not copied, - * so it is important that the caller not free it afterwards. - */ -int -pdb_AppendResource(struct pdb *db, - struct pdb_resource *newrsrc) -{ - struct pdb_resource *rsrc; - - /* Sanity check */ - if (!IS_RSRC_DB(db)) - /* This only works with resource databases */ - return -1; - - /* Check to see if the list is empty */ - if (db->rec_index.rsrc == NULL) - { - db->rec_index.rsrc = newrsrc; - newrsrc->next = NULL; - - db->numrecs++; /* Bump resource counter */ - - return 0; /* Success */ - } - - /* Walk the list to find its end */ - for (rsrc = db->rec_index.rsrc; rsrc->next != NULL; rsrc = rsrc->next) - ; - rsrc->next = newrsrc; - newrsrc->next = NULL; - - db->numrecs++; /* Bump resource counter */ - - return 0; /* Success */ -} - -/* pdb_InsertRecord - * Insert 'newrec' into 'db', just after 'prev'. If 'prev' is NULL, - * 'newrec' is inserted at the beginning of the list. - * Returns 0 if successful, -1 otherwise. - * 'newrec' is not copied, so it is important that the caller not free it. - */ -int -pdb_InsertRecord(struct pdb *db, /* The database to insert into */ - struct pdb_record *prev, - /* Insert after this record */ - struct pdb_record *newrec) - /* The record to insert */ -{ - /* If 'prev' is NULL, insert at the beginning of the list */ - if (prev == NULL) - { - newrec->next = db->rec_index.rec; - db->rec_index.rec = newrec; - db->numrecs++; /* Increment record count */ - - return 0; /* Success */ - } - - /* XXX - This function doesn't actually check to make sure that - * 'prev' is in 'db'. You could really fuck yourself over with - * this. - * So make it a documented requirement. - */ - /* The new record goes in the middle of the list. Insert it. */ - newrec->next = prev->next; - prev->next = newrec; - db->numrecs++; /* Increment record count */ - - return 0; /* Success */ -} - -#if 0 -/* pdb_InsertResource - * Insert 'newrsrc' into 'db', just after 'prev'. If 'prev' is NULL, 'newrsrc' - * is inserted at the beginning of the list. - * Returns 0 if successful, -1 otherwise. - * 'newrec' is not copied, so it is important that the caller not free it. - */ -int -pdb_InsertResource(struct pdb *db, /* The database to insert into */ - struct pdb_resource *prev, - /* Insert after this resource */ - struct pdb_resource *newrsrc) - /* The resource to insert */ -{ - /* If 'prev' is NULL, insert at the beginning of the list */ - if (prev == NULL) - { - newrsrc->next = db->rec_index.rsrc; - db->rec_index.rsrc = newrsrc; - db->numrecs++; /* Increment record count */ - - return 0; /* Success */ - } - - /* XXX - This function doesn't actually check to make sure that - * 'prev' is in 'db'. You could really fuck yourself over with - * this. - * So make it a documented requirement. - */ - /* The new resource goes in the middle of the list. Insert it. */ - newrsrc->next = prev->next; - prev->next = newrsrc; - db->numrecs++; /* Increment record count */ - - return 0; /* Success */ -} -#endif - -/* new_Record - * Create a new record from the given arguments, and return a pointer to - * it. Returns NULL in case of error. - * The record data is copied, so the caller needs to take care of freeing - * 'data'. - * - * The 'attributes' and 'category' arguments are combined into one field: - * if the new record is deleted, then the category is silently dropped. - * Otherwise, the category occupies the bottom 4 bits of the - * attributes/category field. - */ -struct pdb_record * -new_Record(const ubyte flags, - const ubyte category, - const udword id, - const uword len, - const ubyte *data) -{ - struct pdb_record *retval; - - PDB_TRACE(6) - { - fprintf(stderr, "new_Record: Creating new record:\n"); - fprintf(stderr, "\tflags == 0x%02x\n", flags); - fprintf(stderr, "\tcategory == 0x%02x\n", category); - fprintf(stderr, "\tid == 0x%08lx\n", (unsigned long) id); - fprintf(stderr, "\tlen == %d\n", len); - debug_dump(stderr, "NEW", data, len); - } - - /* Allocate the record to be returned */ - if ((retval = (struct pdb_record *) malloc(sizeof(struct pdb_record))) - == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "new_Record"); - return NULL; - } - - /* Initialize the new record */ - retval->next = NULL; - retval->offset = 0L; - retval->flags = flags; - retval->category = category; - retval->id = id; - - /* Allocate space to put the record data */ - if (len == 0) - { - /* Special case: the record has no data (e.g., this is an - * expunged record). - */ - retval->data_len = len; - retval->data = NULL; - return retval; - } - - if ((retval->data = (ubyte *) malloc(len)) == NULL) - { - /* Couldn't allocate data portion of record */ - fprintf(stderr, _("%s: can't allocate data.\n"), - "new_Record"); - free(retval); - return NULL; - } - - /* Copy the data to the new record */ - retval->data_len = len; - memcpy(retval->data, data, len); - - return retval; /* Success */ -} - -/* new_Resource - * Create a new resource from the given arguments, and return a pointer to - * it. Returns NULL in case of error. - * The resource data is copied, so the caller needs to take care of freeing - * 'data'. - */ -struct pdb_resource * -new_Resource(const udword type, - const uword id, - const uword len, - const ubyte *data) -{ - struct pdb_resource *retval; - - PDB_TRACE(6) - { - fprintf(stderr, "new_Resource: Creating new resource:\n"); - fprintf(stderr, "\ttype == 0x%08lx (%c%c%c%c)\n", - (unsigned long) type, - (int) ((type >> 24) & 0xff), - (int) ((type >> 16) & 0xff), - (int) ((type >> 8) & 0xff), - (int) (type & 0xff)); - fprintf(stderr, "\tid == 0x%04x\n", (unsigned) id); - fprintf(stderr, "\tlen == %d\n", len); - debug_dump(stderr, "NEW", data, len); - } - - /* Allocate the resource to be returned */ - if ((retval = (struct pdb_resource *) - malloc(sizeof(struct pdb_resource))) == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "new_Resource"); - return NULL; - } - - /* Initialize the new resource */ - retval->next = NULL; - retval->offset = 0L; - retval->type = type; - retval->id = id; - - /* Allocate space to put the resource data */ - if (len == 0) - { - /* Special case: zero-length resource (dunno if this should - * ever happen, but this way we avoid malloc(0). - */ - retval->data_len = len; - retval->data = NULL; - return retval; - } - - if ((retval->data = (ubyte *) malloc(len)) == NULL) - { - /* Couldn't allocate data portion of resource */ - fprintf(stderr, _("%s: can't allocate data.\n"), - "new_Resource"); - free(retval); - return NULL; - } - - /* Copy the data to the new resource */ - retval->data_len = len; - memcpy(retval->data, data, len); - - return retval; /* Success */ -} - -/* pdb_CopyRecord - * Make a copy of record 'rec' in database 'db' (and its data), and return - * it. The new record is allocated by pdb_CopyRecord(), so the caller has - * to take care of freeing it. - * Returns a pointer to the new copy, or NULL in case of error. - */ -struct pdb_record *pdb_CopyRecord( - const struct pdb *db, - const struct pdb_record *rec) -{ - struct pdb_record *retval; - - /* Allocate the record to be returned */ - if ((retval = (struct pdb_record *) malloc(sizeof(struct pdb_record))) - == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_CopyRecord"); - return NULL; - } - - retval->next = NULL; /* For cleanliness */ - - /* Copy the old record to the new copy */ - retval->offset = rec->offset; - retval->flags = rec->flags; - retval->category = rec->category; - retval->id = rec->id; - - /* Allocate space for the record data itself */ - if ((retval->data = (ubyte *) malloc(rec->data_len)) == NULL) - { - fprintf(stderr, _("%s: can't allocate record data for " - "\"%.*s\".\n"), - "pdb_CopyRecord", - PDB_DBNAMELEN, db->name); - free(retval); - return NULL; - } - - /* Copy the record data */ - retval->data_len = rec->data_len; - memcpy(retval->data, rec->data, retval->data_len); - - return retval; /* Success */ -} - -/* pdb_CopyResource - * Make a copy of resource 'rsrc' in database 'db' (and its data), and - * return it. The new record is allocated by pdb_CopyResource(), so the - * caller has to take care of freeing it. - * Returns a pointer to the new copy, or NULL in case of error. - */ -struct pdb_resource *pdb_CopyResource( - const struct pdb *db, - const struct pdb_resource *rsrc) -{ - struct pdb_resource *retval; - - /* Allocate the resource to be returned */ - if ((retval = (struct pdb_resource *) - malloc(sizeof(struct pdb_resource))) == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_CopyResource"); - return NULL; - } - - retval->next = NULL; /* For cleanliness */ - - /* Copy the old resource to the new copy */ - retval->type = rsrc->type; - retval->id = rsrc->id; - retval->offset = rsrc->offset; - - /* Allocate space for the record data itself */ - if ((retval->data = (ubyte *) malloc(rsrc->data_len)) == NULL) - { - fprintf(stderr, _("%s: can't allocate resource data for " - "\"%.*s\".\n"), - "pdb_CopyResource", - PDB_DBNAMELEN, db->name); - free(retval); - return NULL; - } - - /* Copy the resource data */ - retval->data_len = rsrc->data_len; - memcpy(retval->data, rsrc->data, retval->data_len); - - return retval; /* Success */ -} - -/*** Helper functions ***/ - -/* get_file_length - * Return the length of a file, in bytes. In case of error, returns ~0. - */ -static uword -get_file_length(int fd) -{ - off_t here; - off_t eof; - - /* Get the current position within the file */ - here = lseek(fd, 0L, SEEK_CUR); - if (here < 0) - /* The file isn't seekable, presumably either because it - * isn't open, or because it's a pipe/socket/FIFO/tty. - */ - return ~0; - - /* Go to the end of the file */ - eof = lseek(fd, 0L, SEEK_END); - - /* And return to where we were before */ - lseek(fd, here, SEEK_SET); - - return (uword) (eof - here); -} - -/* pdb_LoadHeader - * Read the header of a pdb file, and fill in the appropriate fields in - * 'db'. - */ -int -pdb_LoadHeader(int fd, - struct pdb *db) -{ - int err; - static ubyte buf[PDB_HEADER_LEN]; - /* Buffer to hold the file header */ - const ubyte *rptr; /* Pointer into buffers, for reading */ - - /* Read the header */ - if ((err = read(fd, buf, PDB_HEADER_LEN)) != PDB_HEADER_LEN) - { - perror("pdb_LoadHeader: read"); - return -1; - } - - /* Parse the database header */ - rptr = buf; - memcpy(db->name, buf, PDB_DBNAMELEN); - rptr += PDB_DBNAMELEN; - db->attributes = get_uword(&rptr); - db->version = get_uword(&rptr); - db->ctime = get_udword(&rptr); - db->mtime = get_udword(&rptr); - db->baktime = get_udword(&rptr); - db->modnum = get_udword(&rptr); - db->appinfo_offset = get_udword(&rptr); - db->sortinfo_offset = get_udword(&rptr); - db->type = get_udword(&rptr); - db->creator = get_udword(&rptr); - db->uniqueIDseed = get_udword(&rptr); - - PDB_TRACE(5) - { - time_t t; - - fprintf(stderr, "\tname: \"%s\"\n", db->name); - fprintf(stderr, "\tattributes: 0x%04x", db->attributes); - if (db->attributes & PDB_ATTR_RESDB) - fprintf(stderr, " RESDB"); - if (db->attributes & PDB_ATTR_RO) fprintf(stderr, " RO"); - if (db->attributes & PDB_ATTR_APPINFODIRTY) - fprintf(stderr, " APPINFODIRTY"); - if (db->attributes & PDB_ATTR_BACKUP) - fprintf(stderr, " BACKUP"); - if (db->attributes & PDB_ATTR_OKNEWER) - fprintf(stderr, " OKNEWER"); - if (db->attributes & PDB_ATTR_RESET) fprintf(stderr, " RESET"); - if (db->attributes & PDB_ATTR_NOCOPY) - fprintf(stderr, " NOCOPY"); - if (db->attributes & PDB_ATTR_STREAM) - fprintf(stderr, " STREAM"); - if (db->attributes & PDB_ATTR_OPEN) - fprintf(stderr, " OPEN"); - fprintf(stderr, "\n"); - fprintf(stderr, "\tversion: %u\n", db->version); - t = db->ctime - EPOCH_1904; - fprintf(stderr, "\tctime: %lu %s", (unsigned long) db->ctime, - ctime(&t)); - t = db->mtime - EPOCH_1904; - fprintf(stderr, "\tmtime: %lu %s", (unsigned long) db->mtime, - ctime(&t)); - t = db->baktime - EPOCH_1904; - fprintf(stderr, "\tbaktime: %lu %s", (unsigned long) db->baktime, - ctime(&t)); - fprintf(stderr, "\tmodnum: %lu\n", (unsigned long) db->modnum); - fprintf(stderr, "\tappinfo_offset: 0x%08lx\n", - (unsigned long) db->appinfo_offset); - fprintf(stderr, "\tsortinfo_offset: 0x%08lx\n", - (unsigned long) db->sortinfo_offset); - fprintf(stderr, "\ttype: '%c%c%c%c' (0x%08lx)\n", - (char) (db->type >> 24) & 0xff, - (char) (db->type >> 16) & 0xff, - (char) (db->type >> 8) & 0xff, - (char) db->type & 0xff, - (unsigned long) db->type); - fprintf(stderr, "\tcreator: '%c%c%c%c' (0x%08lx)\n", - (char) (db->creator >> 24) & 0xff, - (char) (db->creator >> 16) & 0xff, - (char) (db->creator >> 8) & 0xff, - (char) db->creator & 0xff, - (unsigned long) db->creator); - fprintf(stderr, "\tuniqueIDseed: %lu\n", - (unsigned long) db->uniqueIDseed); - } - - return 0; /* Success */ -} - -/* pdb_LoadRecListHeader - * Load the record list header from a pdb file, and fill in the appropriate - * fields in 'db'. - */ -static int -pdb_LoadRecListHeader(int fd, - struct pdb *db) -{ - int err; - static ubyte buf[PDB_RECORDLIST_LEN]; - const ubyte *rptr; /* Pointer into buffers, for reading */ - - /* Read the record list header */ - if ((err = read(fd, buf, PDB_RECORDLIST_LEN)) != PDB_RECORDLIST_LEN) - { - perror("pdb_LoadRecListHeader: read2"); - return -1; - } - - /* Parse the record list */ - rptr = buf; - db->next_reclistID = get_udword(&rptr); - db->numrecs = get_uword(&rptr); - - PDB_TRACE(6) - { - fprintf(stderr, "\tnextID: %ld\n", (long) db->next_reclistID); - fprintf(stderr, "\tlen: %u\n", db->numrecs); - } - - return 0; -} - -/* pdb_LoadRsrcIndex - * Read the resource index from a resource database file, and fill in the - * appropriate fields in 'db'. - */ -static int -pdb_LoadRsrcIndex(int fd, - struct pdb *db) -{ - int i; - int err; - uword totalrsrcs; /* The real number of resources in the - * database. - */ - - totalrsrcs = db->numrecs; /* Get the number of resources in - * the database. It is necessary to - * remember this here because - * pdb_AppendResource() increments - * db->numrecs in the name of - * convenience. - */ - - if (totalrsrcs == 0) - { - /* There are no resources in this file */ - db->rec_index.rsrc = NULL; - return 0; - } - - /* Read the resource index */ - for (i = 0; i < totalrsrcs; i++) - { - static ubyte inbuf[PDB_RESOURCEIX_LEN]; - /* Input buffer */ - const ubyte *rptr; /* Pointer into buffers, for reading */ - struct pdb_resource *rsrc; - /* New resource entry */ - - /* Allocate the resource entry */ - if ((rsrc = (struct pdb_resource *) - malloc(sizeof(struct pdb_resource))) - == NULL) - return -1; - /* Scribble zeros all over it, just in case */ - memset((void *) rsrc, 0, sizeof(struct pdb_resource)); - - /* Read the next resource index entry */ - if ((err = read(fd, inbuf, PDB_RESOURCEIX_LEN)) != - PDB_RESOURCEIX_LEN) - return -1; - - /* Parse it */ - rptr = inbuf; - rsrc->type = get_udword(&rptr); - rsrc->id = get_uword(&rptr); - rsrc->offset = get_udword(&rptr); - - PDB_TRACE(6) - { - fprintf(stderr, - "\tResource %d: type '%c%c%c%c' (0x%08lx), " - "id %u, offset 0x%08lx\n", - i, - (char) (rsrc->type >> 24) & 0xff, - (char) (rsrc->type >> 16) & 0xff, - (char) (rsrc->type >> 8) & 0xff, - (char) rsrc->type & 0xff, - (unsigned long) rsrc->type, - rsrc->id, - (unsigned long) rsrc->offset); - } - - /* Append the new resource to the list */ - pdb_AppendResource(db, rsrc); /* XXX - Error-checking */ - db->numrecs = totalrsrcs; /* Kludge */ - } - - return 0; -} - -/* pdb_LoadRecIndex - * Read the record index from a record database file, and fill in the - * appropriate fields in 'db'. - */ -static int -pdb_LoadRecIndex(int fd, - struct pdb *db) -{ - int i; - int err; - uword totalrecs; /* The real number of records in the - * database. - */ - - totalrecs = db->numrecs; /* Get the number of records in the - * database. It is necessary to - * remember this here because - * pdb_AppendResource() increments - * db->numrecs in the name of - * convenience. - */ - - if (totalrecs == 0) - { - /* There are no records in this file */ - db->rec_index.rec = NULL; - return 0; - } - - /* Read the record index */ - /* XXX - It would be a Good Thing to check for zero-length records - * here. They've been known to appear as a result of a broken - * conduit. - */ - for (i = 0; i < totalrecs; i++) - { - static ubyte inbuf[PDB_RECORDIX_LEN]; - /* Input buffer */ - const ubyte *rptr; /* Pointer into buffers, for reading */ - struct pdb_record *rec; - /* New record entry */ - ubyte attributes; /* Combined flags+category field */ - - /* Allocate the record entry */ - if ((rec = (struct pdb_record *) - malloc(sizeof(struct pdb_record))) - == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_LoadRecIndex"); - return -1; - } - - /* Scribble zeros all over it, just in case */ - memset((void *) rec, 0, sizeof(struct pdb_record)); - - /* Read the next record index entry */ - if ((err = read(fd, inbuf, PDB_RECORDIX_LEN)) != - PDB_RECORDIX_LEN) - { - fprintf(stderr, _("%s: error reading record index " - "entry for \"%.*s\" (%d bytes): " - "%d.\n"), - "LoadRecIndex", - PDB_DBNAMELEN, db->name, - PDB_RECORDIX_LEN, - err); - perror("read"); - free(rec); - return -1; - } - - /* Parse it */ - rptr = inbuf; - rec->offset = get_udword(&rptr); - attributes = get_ubyte(&rptr); - split_attributes(attributes, &(rec->flags), &(rec->category)); - - rec->id = - ((udword) (get_ubyte(&rptr) << 16)) | - ((udword) (get_ubyte(&rptr) << 8)) | - ((udword) get_ubyte(&rptr)); - - PDB_TRACE(6) - fprintf(stderr, - "\tRecord %d: offset 0x%08lx, flags 0x%02x, " - " category 0x%02x, ID 0x%08lx\n", - i, - (unsigned long) rec->offset, - (unsigned) rec->flags, - rec->category, - (unsigned long) rec->id); - - /* Append the new record to the database */ - pdb_AppendRecord(db, rec); /* XXX - Error-checking */ - db->numrecs = totalrecs; /* Kludge */ - } - - return 0; -} - -/* pdb_LoadAppBlock - * Read the AppInfo block from a database file, and fill in the appropriate - * fields in 'db'. If the file doesn't have an AppInfo block, set it to - * NULL. - */ -static int -pdb_LoadAppBlock(int fd, - struct pdb *db) -{ - int err; - udword next_off; /* Offset of the next thing in the file - * after the AppInfo block */ - off_t offset; /* Offset into file, for checking */ - - /* Check to see if there even *is* an AppInfo block */ - if (db->appinfo_offset == 0L) - { - /* Nope */ - db->appinfo_len = 0L; - db->appinfo = NULL; - return 0; - } - - /* Figure out how long the AppInfo block is, by comparing its - * offset to that of the next thing in the file. - */ - if (db->sortinfo_offset > 0L) - /* There's a sort block */ - next_off = db->sortinfo_offset; - else if (db->numrecs > 0) - { - /* There's no sort block, but there are records. Get the - * offset of the first one. - */ - if (IS_RSRC_DB(db)) - next_off = db->rec_index.rsrc->offset; - else - next_off = db->rec_index.rec->offset; - } else - /* There is neither sort block nor records, so the AppInfo - * block must go to the end of the file. - */ - next_off = db->file_size; - - /* Subtract the AppInfo block's offset from that of the next thing - * in the file to get the AppInfo block's length. - */ - db->appinfo_len = next_off - db->appinfo_offset; - - /* This is probably paranoid, but what the hell */ - if (db->appinfo_len == 0L) - { - /* An effective no-op */ - db->appinfo = NULL; - return 0; - } - - /* Now that we know the length of the AppInfo block, allocate space - * for it and read it. - */ - if ((db->appinfo = (ubyte *) malloc(db->appinfo_len)) == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_LoadAppBlock"); - return -1; - } - - /* Just out of paranoia, make sure we're at the correct offset in - * the file. Since the two NULs may or may not have appeared in the - * file, the only thing that it makes sense to check is whether - * we've already passed the beginning of the AppInfo block, as - * given by its offset in the header. - */ - offset = lseek(fd, 0L, SEEK_CUR); /* Find out where we are */ - if (offset != db->appinfo_offset) - { - if (offset > (off_t) db->appinfo_offset) - { - /* Oops! We're in the wrong place */ - fprintf(stderr, _("Warning: AppInfo block in \"%.*s\" " - "isn't where I thought it would " - "be.\n" - "Expected 0x%lx, but we're at " - "0x%lx.\n"), - PDB_DBNAMELEN, db->name, - (unsigned long) db->appinfo_offset, (unsigned long) offset); - } - - /* Try to recover */ - offset = lseek(fd, db->appinfo_offset, SEEK_SET); - /* Go to where the AppInfo block - * ought to be */ - if (offset < 0) - { - /* Something's wrong */ - fprintf(stderr, _("Can't find the AppInfo block in " - "\"%.*s\"!\n"), - PDB_DBNAMELEN, db->name); - return -1; - } - } - - /* Read the AppInfo block */ - if ((err = read(fd, db->appinfo, db->appinfo_len)) != db->appinfo_len) - { - perror("pdb_LoadAppBlock: read"); - return -1; - } - PDB_TRACE(6) - debug_dump(stderr, "appinfo, db->appinfo_len); - - return 0; -} - -/* pdb_LoadSortBlock - * Read the sort block from a database file, and fill in the appropriate - * fields in 'db'. If the file doesn't have a sort block, set it to NULL. - * - * XXX - Largely untested, since not that many databases have sort blocks. - * But it's basically just a clone of pdb_LoadAppBlock(), so it should be - * okay. - */ -static int -pdb_LoadSortBlock(int fd, - struct pdb *db) -{ - int err; - localID next_off; /* Offset of the next thing in the file - * after the sort block */ - off_t offset; /* Offset into file, for checking */ - - /* Check to see if there even *is* a sort block */ - if (db->sortinfo_offset == 0L) - { - /* Nope */ - db->sortinfo_len = 0L; - db->sortinfo = NULL; - return 0; - } - - /* Figure out how long the sort block is, by comparing its - * offset to that of the next thing in the file. - */ - if (db->numrecs > 0) - { - /* There are records. Get the offset of the first one. - */ - if (IS_RSRC_DB(db)) - next_off = db->rec_index.rsrc->offset; - else - next_off = db->rec_index.rec->offset; - } else - /* There are no records, so the sort block must go to the - * end of the file. - */ - next_off = db->file_size; - - /* Subtract the sort block's offset from that of the next thing - * in the file to get the sort block's length. - */ - db->sortinfo_len = next_off - db->sortinfo_offset; - - /* This is probably paranoid, but what the hell */ - if (db->sortinfo_len == 0L) - { - /* An effective no-op */ - db->sortinfo = NULL; - return 0; - } - - /* Now that we know the length of the sort block, allocate space - * for it and read it. - */ - if ((db->sortinfo = (ubyte *) malloc(db->sortinfo_len)) == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_LoadSortBlock"); - return -1; - } - - /* Just out of paranoia, make sure we're at the correct offset in - * the file. Since the two NULs may or may not have appeared in the - * file, the only thing that it makes sense to check is whether - * we've already passed the beginning of the sort block, as given - * by its offset in the header. - */ - offset = lseek(fd, 0L, SEEK_CUR); /* Find out where we are */ - if (offset != db->sortinfo_offset) - { - if (offset > (off_t) db->sortinfo_offset) - { - /* Oops! We're in the wrong place */ - fprintf(stderr, _("Warning: sort block in \"%.*s\" " - "isn't where I thought it would " - "be.\n" - "Expected 0x%lx, but we're at " - "0x%lx.\n"), - PDB_DBNAMELEN, db->name, - (unsigned long) db->sortinfo_offset, - (unsigned long) offset); - } - - /* Try to recover */ - offset = lseek(fd, db->sortinfo_offset, SEEK_SET); - /* Go to where the sort block - * ought to be */ - if (offset < 0) - { - /* Something's wrong */ - fprintf(stderr, _("Can't find the sort block in " - "\"%.*s\"!\n"), - PDB_DBNAMELEN, db->name); - return -1; - } - } - - /* Read the sort block */ - if ((err = read(fd, db->sortinfo, db->sortinfo_len)) != - db->sortinfo_len) - { - perror("pdb_LoadSortBlock: read"); - return -1; - } - PDB_TRACE(6) - debug_dump(stderr, "sortinfo, db->sortinfo_len); - - return 0; -} - -/* pdb_LoadResources - * Read each resource in turn from a resource database file. - */ -static int -pdb_LoadResources(int fd, - struct pdb *db) -{ - int i; - int err; - struct pdb_resource *rsrc; - - /* This assumes that the resource list has already been created by - * 'pdb_LoadRsrcIndex()'. - */ - for (i = 0, rsrc = db->rec_index.rsrc; - i < db->numrecs; - i++, rsrc = rsrc->next) - { - off_t offset; /* Current offset, for checking */ - udword next_off; /* Offset of next resource in file */ - - /* Sanity check: make sure we haven't stepped off the end - * of the list. - */ - if (rsrc == NULL) - { - fprintf(stderr, _("Hey! I can't find the %dth " - "resource in \"%.*s\"!\n"), - i, - PDB_DBNAMELEN, db->name); - return -1; - } - - PDB_TRACE(5) - fprintf(stderr, - "Reading resource %d (type '%c%c%c%c')\n", - i, - (char) (rsrc->type >> 24) & 0xff, - (char) (rsrc->type >> 16) & 0xff, - (char) (rsrc->type >> 8) & 0xff, - (char) rsrc->type & 0xff); - - /* Out of paranoia, make sure we're in the right place. - * Since the two NULs may or may not have appeared in the - * file, the only thing that it makes sense to check is - * whether we've already passed the beginning of the - * resource, as given by its offset in the resource index. - */ - offset = lseek(fd, 0L, SEEK_CUR); - /* Find out where we are now */ - if (offset != rsrc->offset) - { - if (offset > (off_t) rsrc->offset) - { - fprintf(stderr, _("Warning: resource %d in " - "\"%.*s\" isn't where " - "I thought it would be.\n" - "Expected 0x%lx, but we're " - "at 0x%lx.\n"), - i, - PDB_DBNAMELEN, db->name, - (unsigned long) rsrc->offset, - (unsigned long) offset); - } - - /* Try to recover */ - offset = lseek(fd, rsrc->offset, SEEK_SET); - /* Go to where this - * resource ought to be. - */ - if (offset < 0) - { - /* Something's wrong */ - fprintf(stderr, _("Can't find resource %d in " - "\"%.*s\".\n"), - i, - PDB_DBNAMELEN, db->name); - return -1; - } - } - - /* Okay, now that we're in the right place, find out what - * the next thing in the file is: its offset will tell us - * how much to read. - * It's debatable whether 'i' or 'rsrc' should be - * authoritative for determining the offset of the next - * resource. I'm going to choose 'rsrc', since I think - * that's more likely to be immune to fencepost errors. The - * two should, however, be equivalent. In fact, it might be - * a Good Thing to add a check to make sure. - */ - if (rsrc->next == NULL) - { - /* This is the last resource in the file, so it - * goes to the end of the file. - */ - next_off = db->file_size; - } else { - /* This isn't the last resource. Find the next - * one's offset. - */ - next_off = rsrc->next->offset; - } - - /* Subtract this resource's index from that of the next - * thing, to get the size of this resource. - */ - rsrc->data_len = (uword) (next_off - rsrc->offset); - - /* Allocate space for this resource */ - if ((rsrc->data = (ubyte *) malloc(rsrc->data_len)) == NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_LoadResources"); - return -1; - } - - /* Read the resource */ - if ((err = read(fd, rsrc->data, rsrc->data_len)) != - rsrc->data_len) - { - fprintf(stderr, _("Can't read resource %d in " - "\"%.*s\".\n"), - i, - PDB_DBNAMELEN, db->name); - perror("pdb_LoadResources: read"); - return -1; - } - PDB_TRACE(6) - { - fprintf(stderr, "Contents of resource %d:\n", i); - debug_dump(stderr, "data, - rsrc->data_len); - } - } - - return 0; /* Success */ -} - -/* pdb_LoadRecords - * Read each record in turn from a record database file. - */ -static int -pdb_LoadRecords(int fd, - struct pdb *db) -{ - int i; - int err; - struct pdb_record *rec; - - /* This assumes that the record list has already been created by - * 'pdb_LoadRecIndex()'. - */ - for (i = 0, rec = db->rec_index.rec; - i < db->numrecs; - i++, rec = rec->next) - { - off_t offset; /* Current offset, for checking */ - localID next_off; /* Offset of next resource in file */ - - /* Sanity check: make sure we haven't stepped off the end - * of the list. - */ - if (rec == NULL) - { - fprintf(stderr, _("Hey! I can't find the %dth " - "record in \"%.*s\"!\n"), - i, - PDB_DBNAMELEN, db->name); - return -1; - } - - PDB_TRACE(5) - fprintf(stderr, "Reading record %d (id 0x%08lx)\n", - i, (unsigned long) rec->id); - - /* Out of paranoia, make sure we're in the right place. - * Since the two NULs may or may not have appeared in the - * file, the only thing that it makes sense to check is - * whether we've already passed the beginning of the - * record, as given by its offset in the record index. - */ - offset = lseek(fd, 0L, SEEK_CUR); - /* Find out where we are now */ - if (offset != rec->offset) - { - if (offset > (off_t) rec->offset) - { - fprintf(stderr, _("Warning: record %d in " - "\"%.*s\" isn't where " - "I thought it would be.\n" - "Expected 0x%lx, but we're " - "at 0x%lx.\n"), - i, - PDB_DBNAMELEN, db->name, - (unsigned long) rec->offset, - (unsigned long) offset); - } - - /* Try to recover */ - offset = lseek(fd, rec->offset, SEEK_SET); - /* Go to where this record - * ought to be. */ - if (offset < 0) - { - /* Something's wrong */ - fprintf(stderr, _("Can't find record %d in " - "\"%.*s\".\n"), - i, - PDB_DBNAMELEN, db->name); - return -1; - } - } - - /* Okay, now that we're in the right place, find out what - * the next thing in the file is: its offset will tell us - * how much to read. - * It's debatable whether 'i' or 'rec' should be - * authoritative for determining the offset of the next - * resource. I'm going to choose 'rec', since I think - * that's more likely to be immune from fencepost errors. - * The two should, however, be equivalent. In fact, it - * might be a Good Thing to add a check to make sure. - */ - if (rec->next == NULL) - { - /* This is the last record in the file, so it goes - * to the end of the file. - */ - next_off = db->file_size; - } else { - /* This isn't the last record. Find the next one's - * offset. - */ - next_off = rec->next->offset; - } - - /* Subtract this record's index from that of the next one, - * to get the size of this record. - */ - rec->data_len = (uword) (next_off - rec->offset); - - /* Allocate space for this record - * If there's a record with length zero, don't pass that to - * malloc(). This is most likely due to a broken conduit. - * XXX - The Right Thing to do would be not to read - * zero-length records, but that would involve fixing the - * record index. - */ - if (rec->data_len > 0) - { - if ((rec->data = (ubyte *) malloc(rec->data_len)) == - NULL) - { - fprintf(stderr, _("%s: Out of memory.\n"), - "pdb_LoadRecords"); - return -1; - } - - /* Read the record */ - if ((err = read(fd, rec->data, rec->data_len)) != - rec->data_len) - { - fprintf(stderr, _("Can't read record %d in " - "\"%.*s\".\n"), - i, - PDB_DBNAMELEN, db->name); - perror("pdb_LoadRecords: read"); - return -1; - } - - PDB_TRACE(6) - { - fprintf(stderr, "Contents of record %d:\n", i); - debug_dump(stderr, "data, - rec->data_len); - } - } - } - - return 0; /* Success */ -} - - /* This is for Emacs's benefit: - * Local Variables: *** - * fill-column: 75 *** - * End: *** - */ -#endif /* PDBFMTS_DISABLED */ diff --git a/coldsync/pdb.h b/coldsync/pdb.h deleted file mode 100644 index 1d34d23c4..000000000 --- a/coldsync/pdb.h +++ /dev/null @@ -1,273 +0,0 @@ -/* pdb.h - * - * Definitions and such for Palm databases. - * - * Copyright (C) 1999-2000, Andrew Arensburger. - * You may distribute this file under the terms of the Artistic - * License, as specified in the README file. - * - * $Id: pdb.h,v 1.1 2002/08/16 06:13:10 robertl Exp $ - */ -#ifndef _pdb_h_ -#define _pdb_h_ - -/* XXX - Add a type (and support functions) for those ubitquitous - * 4-character IDs. - */ - -#define EPOCH_1904 2082844800L /* Difference, in seconds, between - * Palm's epoch (Jan. 1, 1904) and - * Unix's epoch (Jan. 1, 1970). - */ - -#define PDB_DBNAMELEN 32 /* Length of name field in database - * header */ - -/* Database attribute flags */ -#define PDB_ATTR_RESDB 0x0001 /* This is a resource database. - * Resource databases are usually - * saved in files with ".prc" - * extensions. Other databases are - * saved with a ".pdb" extension. - */ -#define PDB_ATTR_RO 0x0002 /* Read-only database */ -#define PDB_ATTR_APPINFODIRTY 0x0004 /* App info block is dirty */ -#define PDB_ATTR_BACKUP 0x0008 /* Back up the database if no - * app-specific conduit exists */ -#define PDB_ATTR_OKNEWER 0x0010 /* Tells the backup conduit that - * it's okay to install a newer - * version of this database with a - * different name if this one is - * open. Usually used for the - * Graffiti Shortcuts database. - */ -#define PDB_ATTR_RESET 0x0020 /* Reset the Palm after the - * database is installed */ -#define PDB_ATTR_NOCOPY 0x0040 /* Database should not be copied(?) */ -#define PDB_ATTR_STREAM 0x0080 /* Database is used for file stream - * implementation(?). - */ -#define PDB_ATTR_OPEN 0x8000 /* Database is open */ - -/* Record attributes - * These are the attributes that individual records in a database can have. - * I've taken the liberty of giving them different names from Palm's, since - * Palm's names are rather confusing. - * - * PDB_REC_PRIVATE is set on a record that has been marked "private" by the - * user. It is not encrypted, and if the desktop asks for this record, the - * Palm will not refuse or ask for a password. In short, the Palm needs to - * trust the desktop. - * - * PDB_REC_DIRTY is set on a record whose contents have been modified since - * the last sync. If the user deletes a record without modifying it, - * PDB_REC_DIRTY will not be set, but if he modifies it, then deletes it, - * then both PDB_REC_DIRTY and PDB_REC_DELETED will be set. - * - * PDB_REC_DELETED is set on a record that has been deleted by the user - * since the last sync. Unfortunately, it looks as if not all applications - * are polite enough to set this flag, so you have to go with - * PDB_REC_ARCHIVE and PDB_REC_EXPUNGED. - * - * If the user chose the "Save archive copy on PC" option when deleting a - * record, then the PDB_REC_ARCHIVE bit will be set on the record (with any - * luck, so will PDB_REC_DELETED). - * - * If the user did not choose the "Save archive copy on PC" option when - * deleting a record, the PDB_REC_EXPUNGED bit will be set on the record - * (as will PDB_REC_DELETED, perhaps). Apparently, what happens is this: - * when the user deletes a record, a copy is left around so that HotSync - * will know to delete this record. However, if the user chose not to keep - * a copy, then, in order to conserve memory, the Palm will delete the - * record data, although it will keep a copy of the record header for - * HotSync. - */ -#define PDB_REC_EXPUNGED 0x80 /* The contents of this record have - * been deleted, leaving only the - * record info. (Palm calls this - * 'dlpRecAttrDeleted'.) - */ -#define PDB_REC_DIRTY 0x40 /* Record has been modified. (Palm - * calls this 'dlpRecAttrDirty'.) - */ -#define PDB_REC_DELETED 0x20 /* This record has been deleted. - * (Palm calls this - * 'dlpRecAttrBusy'.) - */ -#define PDB_REC_PRIVATE 0x10 /* Record is private: don't show to - * anyone without asking for a - * password. (Palm calls this - * 'dlpRecAttrSecret'.) - */ -#define PDB_REC_ARCHIVE 0x08 /* This record should be archived - * at the next sync. (Palm calls - * this 'dlpRecAttrArchived'.) - */ - -typedef udword localID; /* Local (card-relative) chunk ID - * (basically, a pointer that can - * be used as a unique ID). - */ - -#define PDB_HEADER_LEN 72 /* Length of header in a file */ -#define PDB_RECORDLIST_LEN 6 /* Length of record index header in - * file */ - -/* pdb_record - * A plain old record, containing arbitrary data. - */ -struct pdb_record -{ - struct pdb_record *next; /* Next record on linked list */ - localID offset; /* Offset of record in file */ - ubyte flags; /* Record flags (PDB_REC_*) */ - ubyte category; /* Record's category */ - udword id; /* Record's unique ID. Actually, - * only the bottom 3 bytes are - * stored in the file, but for - * everything else, it's much - * easier to just consider this a - * 32-bit integer. - */ - uword data_len; /* Length of this record */ - ubyte *data; /* This record's data */ -}; -#define PDB_RECORDIX_LEN 8 /* Size of a pdb_record in a file */ - -/* pdb_resource - * Mac hackers should feel at home here: the type of a resource is really a - * 4-character category identifier, and the ID is an integer within that - * category. - */ -struct pdb_resource -{ - struct pdb_resource *next; /* Next resource on linked list */ - udword type; /* Resource type */ - uword id; /* Resource ID */ - localID offset; /* Offset of resource in file */ - uword data_len; /* Length of this resource */ - ubyte *data; /* This resource's data */ -}; -#define PDB_RESOURCEIX_LEN 10 /* Size of a pdb_resource in a file */ - -/* pdb - * Structure of a Palm database (file), both resource databases (.prc) and - * record databases (.pdb). - */ -struct pdb -{ - long file_size; /* Total length of file */ - - char name[PDB_DBNAMELEN]; /* Database name */ - uword attributes; /* Database attributes */ - uword version; /* Database version */ - - udword ctime; /* Creation time */ - udword mtime; /* Time of last modification */ - udword baktime; /* Time of last backup */ - udword modnum; /* Modification number */ - /* XXX - What exactly is the modification number? - * Does it get incremented each time you make any - * kind of change to the database? - */ - localID appinfo_offset; /* Offset of AppInfo block in the - * file */ - localID sortinfo_offset; /* Offset of sort block in the file */ - - udword type; /* Database type */ - udword creator; /* Database creator */ - - udword uniqueIDseed; /* Used to generate unique IDs for - * records and resources. Only the - * lower 3 bytes are used. The high - * byte is for alignment. - */ - - localID next_reclistID; /* ID of next record index in the - * file. In practice, this field is - * always zero. - */ - uword numrecs; /* Number of records/resources in - * the file. - */ - - long appinfo_len; /* Length of AppInfo block */ - void *appinfo; /* Optional AppInfo block */ - long sortinfo_len; /* Length of sort block */ - void *sortinfo; /* Optional sort block */ - - /* Record/resource list. Each of these is actually a linked list, - * to make it easy to insert and delete records. - */ - union { - struct pdb_record *rec; - struct pdb_resource *rsrc; - } rec_index; -}; - -/* Convenience macros */ -#define IS_RSRC_DB(db) ((db)->attributes & PDB_ATTR_RESDB) - /* Is this a resource database? If - * not, it must be a record - * database. - */ - -extern int pdb_trace; /* Debugging level for PDB stuff */ - -extern struct pdb *new_pdb(); -extern void free_pdb(struct pdb *db); -extern void pdb_FreeRecord(struct pdb_record *rec); -extern void pdb_FreeResource(struct pdb_resource *rsrc); -extern struct pdb *pdb_Read(int fd); /* Load a pdb from a file. */ -extern int pdb_Write(const struct pdb *db, int fd); - /* Write a pdb to a file */ -extern struct pdb_record *pdb_FindRecordByID( - const struct pdb *db, - const udword id); -extern struct pdb_record *pdb_FindRecordByIndex( - const struct pdb *db, - const uword index); -extern int pdb_DeleteRecordByID( - struct pdb *db, - const udword id); -extern int pdb_AppendRecord(struct pdb *db, struct pdb_record *newrec); -extern int pdb_AppendResource(struct pdb *db, struct pdb_resource *newrsrc); -extern int pdb_InsertRecord( - struct pdb *db, - struct pdb_record *prev, - struct pdb_record *newrec); -extern int pdb_InsertResource( - struct pdb *db, - struct pdb_resource *prev, - struct pdb_resource *newrsrc); -extern struct pdb_record *new_Record( - const ubyte attributes, - const ubyte category, - const udword id, - const uword len, - const ubyte *data); -extern struct pdb_resource *new_Resource( - const udword type, - const uword id, - const uword len, - const ubyte *data); -extern struct pdb_record *pdb_CopyRecord( - const struct pdb *db, - const struct pdb_record *rec); -extern struct pdb_resource *pdb_CopyResource( - const struct pdb *db, - const struct pdb_resource *rsrc); -extern int pdb_LoadHeader(int fd, struct pdb *db); - -/* XXX - Functions to write: -pdb_setAppInfo set the appinfo block -pdb_setSortInfo set the sortinfo block -*/ - -#endif /* _pdb_h_ */ - - /* This is for Emacs's benefit: - * Local Variables: *** - * fill-column: 75 *** - * End: *** - */ diff --git a/coldsync/util.c b/coldsync/util.c deleted file mode 100644 index 3afb545d7..000000000 --- a/coldsync/util.c +++ /dev/null @@ -1,293 +0,0 @@ -/* util.c - * - * Misc. utility functions. - * - * Copyright (C) 1999, Andrew Arensburger. - * You may distribute this file under the terms of the Artistic - * License, as specified in the README file. - * - * The get_*() functions are used to extract values out of strings of - * ubytes and convert them to the native format. - * The put_*() functions, conversely, are used to take a value in the - * native format, convert them to Palm (big-endian) format, and write - * them to a ubyte string. - * - * $Id: util.c,v 1.6 2006/05/07 02:14:35 robertl Exp $ - */ - -#include "config.h" -#include "cs-config.h" -#if PDBFMTS_ENABLED -#include -#include /* For isprint() */ -#include - -#ifndef EPOCH_1904 -# define EPOCH_1904 2082844800L /* Difference, in seconds, between - * Palm's epoch (Jan. 1, 1904) and - * Unix's epoch (Jan. 1, 1970). - */ -#endif /* EPOCH_1904 */ - -/* XXX - Most of the functions below really ought to be inlined. Not sure - * how to do this portably, though. - */ - -INLINE ubyte -peek_ubyte(const ubyte *buf) -{ - return buf[0]; -} - -INLINE uword -peek_uword(const ubyte *buf) -{ - return ((uword) buf[0] << 8) | - buf[1]; -} - -INLINE udword -peek_udword(const ubyte *buf) -{ - return ((uword) buf[0] << 24) | - ((uword) buf[1] << 16) | - ((uword) buf[2] << 8) | - buf[3]; -} - -INLINE ubyte -get_ubyte(const ubyte **buf) -{ - ubyte retval; - - retval = peek_ubyte(*buf); - *buf += SIZEOF_UBYTE; - - return retval; -} - -INLINE void -put_ubyte(ubyte **buf, const ubyte value) -{ - **buf = value; - ++(*buf); -} - -INLINE uword -get_uword(const ubyte **buf) -{ - uword retval; - - retval = peek_uword(*buf); - *buf += SIZEOF_UWORD; - - return retval; -} - -INLINE void -put_uword(ubyte **buf, const uword value) -{ - **buf = (value >> 8) & 0xff; - ++(*buf); - **buf = value & 0xff; - ++(*buf); -} - -INLINE udword -get_udword(const ubyte **buf) -{ - udword retval; - - retval = peek_udword(*buf); - *buf += SIZEOF_UDWORD; - - return retval; -} - -INLINE void -put_udword(ubyte **buf, const udword value) -{ - **buf = (ubyte) ((value >> 24) & 0xff); - ++(*buf); - **buf = (ubyte) ((value >> 16) & 0xff); - ++(*buf); - **buf = (ubyte) ((value >> 8) & 0xff); - ++(*buf); - **buf = (ubyte) (value & 0xff); - ++(*buf); -} -#if TIME -/* XXX - Figure out the timezone hairiness: - * Palms don't have timezones. Hence, the Palm's epoch is Jan. 1, 1904 in - * the local timezone. - * Unless you're syncing across the network, in which case its epoch is - * Jan. 1, 1904 in the timezone it happens to be in (which may not be the - * same as the desktop's timezone). - * Except that there are (I'm sure) tools that add timezones to the Palm. - * These should be consulted. - * Times generated locally are in the local timezone (i.e., the one that - * the desktop machine is in). - */ - -/* time_dlp2time_t - * Convert the DLP time structure into a Unix time_t, and return it. - */ -time_t -time_dlp2time_t(const struct dlp_time *dlpt) -{ - struct tm tm; - - /* Convert the dlp_time into a struct tm, then just use mktime() to - * do the conversion. - */ - tm.tm_sec = dlpt->second; - tm.tm_min = dlpt->minute; - tm.tm_hour = dlpt->hour; - tm.tm_mday = dlpt->day; - tm.tm_mon = dlpt->month - 1; - tm.tm_year = dlpt->year - 1900; - tm.tm_wday = 0; - tm.tm_yday = 0; - tm.tm_isdst = 0; -#if HAVE_TM_ZONE - tm.tm_gmtoff = 0; - tm.tm_zone = NULL; -#else -/* XXX - ANSI doesn't allow #warning, and we're not using the timezone for - * anything yet. - */ -/* #warning You do not have tm_zone */ -#endif - - return mktime(&tm); -} - -/* time_dlp2palmtime - * Convert a DLP time structure into a Palm time_t (number of seconds since - * Jan. 1. 1904), and return it. - */ -udword -time_dlp2palmtime(const struct dlp_time *dlpt) -{ - time_t now; /* The time, as a Unix time_t */ - struct tm tm; - - /* Convert the dlp_time into a struct tm, use mktime() to do the - * conversion, and add the difference in epochs. - */ - tm.tm_sec = dlpt->second; - tm.tm_min = dlpt->minute; - tm.tm_hour = dlpt->hour; - tm.tm_mday = dlpt->day; - tm.tm_mon = dlpt->month - 1; - tm.tm_year = dlpt->year - 1900; - tm.tm_wday = 0; - tm.tm_yday = 0; - tm.tm_isdst = 0; -#if HAVE_TM_ZONE - tm.tm_gmtoff = 0; - tm.tm_zone = NULL; -#endif - - now = mktime(&tm); - now += EPOCH_1904; - - return now; -} - -/* time_time_t2dlp - * Convert a Unix time_t into a DLP time structure. Put the result in - * 'dlpt'. - */ -void -time_time_t2dlp(const time_t t, - struct dlp_time *dlpt) -{ - struct tm *tm; - - tm = localtime(&t); /* Break 't' down into components */ - - /* Copy the relevant fields over to 'dlpt' */ - dlpt->year = tm->tm_year + 1900; - dlpt->month = tm->tm_mon + 1; - dlpt->day = tm->tm_mday; - dlpt->hour = tm->tm_hour; - dlpt->minute = tm->tm_min; - dlpt->second = tm->tm_sec; -} - -/* time_palmtime2dlp - - * Convert a Palm time (seconds since the Jan. 1, 1904) to a DLP time - * structure. Put the result in 'dlpt'. - */ -void -time_palmtime2dlp(const udword palmt, - struct dlp_time *dlpt) -{ - struct tm *tm; -time_t t; - - /* Convert the Palm time to a Unix time_t */ - t = palmt - EPOCH_1904; - - /* Break the Unix time_t into components */ - tm = localtime(&t); - - /* Copy the relevant fields over to 'dlpt' */ - dlpt->year = tm->tm_year + 1900; - dlpt->month = tm->tm_mon + 1; - dlpt->day = tm->tm_mday; - dlpt->hour = tm->tm_hour; - dlpt->minute = tm->tm_min; - dlpt->second = tm->tm_sec; -} -#endif - -/* debug_dump - * Dump the contents of an array of ubytes to stderr, for debugging. - */ -void -debug_dump(FILE *outfile, const char *prefix, - const ubyte *buf, const udword len) -{ - unsigned int lineoff; - - for (lineoff = 0; lineoff < len; lineoff += 16) - { - int i; - - fprintf(outfile, "%s ", prefix); - for (i = 0; i < 16; i++) - { - if (lineoff + i < len) - { - /* Regular bytes */ - fprintf(outfile, "%02x ", buf[lineoff+i]); - } else { - /* Filler at the end of the line */ - fprintf(outfile, " "); - } - } - fprintf(outfile, " | "); - for (i = 0; i < 16; i++) - { - if (lineoff + i < len) - { - /* Regular bytes */ - if (isprint(buf[lineoff+i])) - fprintf(outfile, "%c", buf[lineoff+i]); - else - fprintf(outfile, "."); - } else - break; - } - fprintf(outfile, "\n"); - } -} - /* This is for Emacs's benefit: - * Local Variables: *** - * fill-column: 75 *** - * End: *** - */ -#endif diff --git a/compegps.c b/compegps.c index 3156c55bd..a47400d8c 100644 --- a/compegps.c +++ b/compegps.c @@ -106,16 +106,11 @@ static void fix_datum(double *lat, double *lon) { double amt; - static int wgs84; - - if (wgs84 == 0) { - wgs84 = GPS_Lookup_Datum_Index("WGS 84"); - } /* * Avoid FP jitter in the common case. */ - if (input_datum != wgs84) { + if (input_datum != DATUM_WGS84) { GPS_Math_Known_Datum_To_WGS84_M(*lat, *lon, 0.0, lat, lon, &amt, input_datum); } @@ -210,8 +205,7 @@ parse_wpt_info(const char *buff, waypoint *wpt) /* "w" */ case 7: break; /* ??? */ case 8: /* radius */ fx = atof(c); - if (fx > 0) - wpt->proximity = fx; + if (fx > 0) WAYPT_SET(wpt, proximity, fx); break; } } @@ -341,7 +335,7 @@ static void compegps_rd_init(const char *fname) { fin = gbfopen(fname, "rb", MYNAME); - input_datum = GPS_Lookup_Datum_Index("WGS 84"); + input_datum = DATUM_WGS84; } static void @@ -455,7 +449,7 @@ write_waypt_cb(const waypoint *wpt) gbfprintf(fout, " %s", wpt->description); gbfprintf(fout, "\n"); - if ((wpt->icon_descr != NULL) || (wpt->proximity > 0.0) || \ + if ((wpt->icon_descr != NULL) || (wpt->wpt_flags.proximity) || \ (option_icon != NULL)) { char *icon = option_icon; @@ -464,7 +458,7 @@ write_waypt_cb(const waypoint *wpt) gbfprintf(fout, "w %s,0,0.0,16777215,255,1,7,,%.1f\n", (icon != NULL) ? icon : "Waypoint", - (wpt->proximity > 0.0f) ? wpt->proximity : 0.0); + WAYPT_GET(wpt, proximity, 0)); } xfree(name); } @@ -521,6 +515,7 @@ write_trkpt_cb(const waypoint *wpt) strftime(buff, sizeof(buff), "%d-%b-%y %H:%M:%S", &tm); strupper(buff); } + else strncpy(buff, "01-JAN-70 00:00:00", sizeof(buff)); gbfprintf(fout, "T A %.10f%c%c %.10f%c%c ", fabs(wpt->latitude), 0xBA, (wpt->latitude >= 0) ? 'N' : 'S', diff --git a/configure b/configure index 3e9773f05..d51b46141 100755 --- a/configure +++ b/configure @@ -1,27 +1,56 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for GPSBabel 1.3.3. +# Generated by GNU Autoconf 2.61 for GPSBabel 1.3.4. # # Report bugs to . # -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -31,8 +60,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -46,18 +110,19 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false @@ -65,157 +130,388 @@ fi # Name of the executable. -as_me=`$as_basename "$0" || +as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` +# CDPATH. +$as_unset CDPATH -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no fi + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in + case $as_dir in /*) - if ("$as_dir/$as_base" -c ' + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || + chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -224,7 +520,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -233,48 +550,165 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH +exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` -exec 6>&1 - # # Initializations. # ac_default_prefix=/usr/local +ac_clean_files= ac_config_libobj_dir=. +LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -# This variable seems obsolete. It should probably be removed, and -# only ac_max_sed_lines should be used. -: ${ac_max_here_lines=38} - # Identity of this package. PACKAGE_NAME='GPSBabel' PACKAGE_TARNAME='gpsbabel' -PACKAGE_VERSION='1.3.3' -PACKAGE_STRING='GPSBabel 1.3.3' +PACKAGE_VERSION='1.3.4' +PACKAGE_STRING='GPSBabel 1.3.4' PACKAGE_BUGREPORT='BUG-REPORT-ADDRESS' -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS PACKAGE_RELEASE GBMAJOR GBMINOR GBMICRO build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE FILEINFO RC LIBUSBCONFIG USB_LIBS USB_CFLAGS OSJEEPS GBSER ZLIB EXPAT_LIB EFENCE_LIB GPSBABEL_DEBUG INSTALL_DEBUG DOCDIR LIBOBJS LTLIBOBJS' +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +PACKAGE_RELEASE +GBMAJOR +GBMINOR +GBMICRO +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +SET_MAKE + +CPP +GREP +EGREP +PALM_DB_CMT +FILEINFO +RC +LIBUSBCONFIG +USB_LIBS +USB_CFLAGS +OSJEEPS +GBSER +ZLIB +EXPAT_LIB +EFENCE_LIB +GPSBABEL_DEBUG +INSTALL_DEBUG +DOCDIR +LIBOBJS +LTLIBOBJS' ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + # Initialize some variables set by options. ac_init_help= @@ -301,34 +735,48 @@ x_libraries=NONE # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' +datarootdir='${prefix}/share' +datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' ac_prev= +ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" + eval $ac_prev=\$ac_option ac_prev= continue fi - ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac # Accept the important Cygnus configure options, so we can diagnose typos. - case $ac_option in + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; @@ -350,33 +798,45 @@ do --config-cache | -C) cache_file=config.cache ;; - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) + -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - eval "enable_$ac_feature=no" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "enable_$ac_feature='$ac_optarg'" ;; + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ @@ -403,6 +863,12 @@ do -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; @@ -427,13 +893,16 @@ do | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) + | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) @@ -498,6 +967,16 @@ do | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -550,24 +1029,20 @@ do -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` - case $ac_option in - *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; - *) ac_optarg=yes ;; - esac - eval "with_$ac_package='$ac_optarg'" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` - eval "with_$ac_package=no" ;; + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. @@ -598,8 +1073,7 @@ Try \`$0 --help' for more information." >&2 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } - ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` - eval "$ac_envvar='$ac_optarg'" + eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) @@ -619,27 +1093,19 @@ if test -n "$ac_prev"; then { (exit 1); exit 1; }; } fi -# Be sure to have absolute paths. -for ac_var in exec_prefix prefix +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir do - eval ac_val=$`echo $ac_var` + eval ac_val=\$$ac_var case $ac_val in - [\\/$]* | ?:[\\/]* | NONE | '' ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; - esac -done - -# Be sure to have absolute paths. -for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ - localstatedir libdir includedir oldincludedir infodir mandir -do - eval ac_val=$`echo $ac_var` - case $ac_val in - [\\/$]* | ?:[\\/]* ) ;; - *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; };; + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' @@ -666,70 +1132,76 @@ test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_confdir=`(dirname "$0") 2>/dev/null || + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then + if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 - { (exit 1); exit 1; }; } - else - { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } - fi fi -(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || - { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } -srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` -ac_env_build_alias_set=${build_alias+set} -ac_env_build_alias_value=$build_alias -ac_cv_env_build_alias_set=${build_alias+set} -ac_cv_env_build_alias_value=$build_alias -ac_env_host_alias_set=${host_alias+set} -ac_env_host_alias_value=$host_alias -ac_cv_env_host_alias_set=${host_alias+set} -ac_cv_env_host_alias_value=$host_alias -ac_env_target_alias_set=${target_alias+set} -ac_env_target_alias_value=$target_alias -ac_cv_env_target_alias_set=${target_alias+set} -ac_cv_env_target_alias_value=$target_alias -ac_env_CC_set=${CC+set} -ac_env_CC_value=$CC -ac_cv_env_CC_set=${CC+set} -ac_cv_env_CC_value=$CC -ac_env_CFLAGS_set=${CFLAGS+set} -ac_env_CFLAGS_value=$CFLAGS -ac_cv_env_CFLAGS_set=${CFLAGS+set} -ac_cv_env_CFLAGS_value=$CFLAGS -ac_env_LDFLAGS_set=${LDFLAGS+set} -ac_env_LDFLAGS_value=$LDFLAGS -ac_cv_env_LDFLAGS_set=${LDFLAGS+set} -ac_cv_env_LDFLAGS_value=$LDFLAGS -ac_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_env_CPPFLAGS_value=$CPPFLAGS -ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} -ac_cv_env_CPPFLAGS_value=$CPPFLAGS + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done # # Report the --help message. @@ -738,7 +1210,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures GPSBabel 1.3.3 to adapt to many kinds of systems. +\`configure' configures GPSBabel 1.3.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -758,9 +1230,6 @@ Configuration: -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] -_ACEOF - - cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] @@ -778,15 +1247,22 @@ Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] - --infodir=DIR info documentation [PREFIX/info] - --mandir=DIR man documentation [PREFIX/man] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/gpsbabel] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF @@ -800,7 +1276,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of GPSBabel 1.3.3:";; + short | recursive ) echo "Configuration of GPSBabel 1.3.4:";; esac cat <<\_ACEOF @@ -827,128 +1303,96 @@ Some influential environment variables: CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory - CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have - headers in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF +ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d $ac_dir || continue + test -d "$ac_dir" || continue ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; -esac - -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac - - cd $ac_dir - # Check for guested configure; otherwise get Cygnus style configure. - if test -f $ac_srcdir/configure.gnu; then - echo - $SHELL $ac_srcdir/configure.gnu --help=recursive - elif test -f $ac_srcdir/configure; then - echo - $SHELL $ac_srcdir/configure --help=recursive - elif test -f $ac_srcdir/configure.ac || - test -f $ac_srcdir/configure.in; then - echo - $ac_configure --help +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi - cd $ac_popdir + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } done fi -test -n "$ac_init_help" && exit 0 +test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -GPSBabel configure 1.3.3 -generated by GNU Autoconf 2.59 +GPSBabel configure 1.3.4 +generated by GNU Autoconf 2.61 -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF - exit 0 + exit fi -exec 5>config.log -cat >&5 <<_ACEOF +cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by GPSBabel $as_me 1.3.3, which was -generated by GNU Autoconf 2.59. Invocation command line was +It was created by GPSBabel $as_me 1.3.4, which was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF +exec 5>>config.log { cat <<_ASUNAME ## --------- ## @@ -967,7 +1411,7 @@ uname -v = `(uname -v) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` @@ -981,6 +1425,7 @@ do test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done +IFS=$as_save_IFS } >&5 @@ -1002,7 +1447,6 @@ _ACEOF ac_configure_args= ac_configure_args0= ac_configure_args1= -ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do @@ -1013,7 +1457,7 @@ do -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in @@ -1035,9 +1479,7 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" - # Get rid of the leading space. - ac_sep=" " + ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done @@ -1048,8 +1490,8 @@ $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_ # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. -# WARNING: Be sure not to use single quotes in there, as some shells, -# such as our DU 5.0 friend, will then `close' the trap. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { @@ -1062,20 +1504,34 @@ trap 'exit_status=$? _ASBOX echo # The following way of writing the cache mishandles newlines in values, -{ +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done (set) 2>&1 | - case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) sed -n \ - "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" - ;; + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( *) - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} + esac | + sort +) echo cat <<\_ASBOX @@ -1086,22 +1542,28 @@ _ASBOX echo for ac_var in $ac_subst_vars do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX -## ------------- ## -## Output files. ## -## ------------- ## +## ------------------- ## +## File substitutions. ## +## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do - eval ac_val=$`echo $ac_var` - echo "$ac_var='"'"'$ac_val'"'"'" + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" done | sort echo fi @@ -1113,26 +1575,24 @@ _ASBOX ## ----------- ## _ASBOX echo - sed "/^$/d" confdefs.h | sort + cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 - rm -f core *.core && - rm -rf conftest* confdefs* conf$$* $ac_clean_files && + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status - ' 0 +' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo >confdefs.h +rm -f -r conftest* confdefs.h # Predefined preprocessor variables. @@ -1163,14 +1623,17 @@ _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" fi -for ac_site_file in $CONFIG_SITE; do +shift +for ac_site_file +do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} @@ -1186,8 +1649,8 @@ if test -r "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in - [\\/]* | ?:[\\/]* ) . $cache_file;; - *) . ./$cache_file;; + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; esac fi else @@ -1199,12 +1662,11 @@ fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false -for ac_var in `(set) 2>&1 | - sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do +for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val="\$ac_cv_env_${ac_var}_value" - eval ac_new_val="\$ac_env_${ac_var}_value" + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 @@ -1229,8 +1691,7 @@ echo "$as_me: current value: $ac_new_val" >&2;} # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) - ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in @@ -1247,12 +1708,6 @@ echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start ov { (exit 1); exit 1; }; } fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - @@ -1277,11 +1732,16 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu # YYYYMMDD, please, if beta, i.e. "-beta20060413" -# PACKAGE_RELEASE="-beta20061125" +# PACKAGE_RELEASE="-beta20070711" cat >>confdefs.h <<_ACEOF #define PACKAGE_RELEASE "$PACKAGE_RELEASE" @@ -1297,108 +1757,158 @@ GBMICRO=`echo $PACKAGE_VERSION | (IFS="."; read major minor micro; echo $micro)` # AC_CONFIG_SRCDIR([nmea.c]) - ac_config_headers="$ac_config_headers config.h" +ac_config_headers="$ac_config_headers config.h" ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break - elif test -f $ac_dir/install.sh; then + elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break - elif test -f $ac_dir/shtool; then + elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then - { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 -echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi -ac_config_guess="$SHELL $ac_aux_dir/config.guess" -ac_config_sub="$SHELL $ac_aux_dir/config.sub" -ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + # Make sure we can run config.sub. -$ac_config_sub sun4 >/dev/null 2>&1 || - { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 -echo "$as_me: error: cannot run $ac_config_sub" >&2;} +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:$LINENO: checking build system type" >&5 -echo $ECHO_N "checking build system type... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_build_alias=$build_alias -test -z "$ac_cv_build_alias" && - ac_cv_build_alias=`$ac_config_guess` -test -z "$ac_cv_build_alias" && + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } -ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi -echo "$as_me:$LINENO: result: $ac_cv_build" >&5 -echo "${ECHO_T}$ac_cv_build" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac build=$ac_cv_build -build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking host system type" >&5 -echo $ECHO_N "checking host system type... $ECHO_C" >&6 +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_host_alias=$host_alias -test -z "$ac_cv_host_alias" && - ac_cv_host_alias=$ac_cv_build_alias -ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } +fi fi -echo "$as_me:$LINENO: result: $ac_cv_host" >&5 -echo "${ECHO_T}$ac_cv_host" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac host=$ac_cv_host -host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` - - -echo "$as_me:$LINENO: checking target system type" >&5 -echo $ECHO_N "checking target system type... $ECHO_C" >&6 +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_target_alias=$target_alias -test "x$ac_cv_target_alias" = "x" && - ac_cv_target_alias=$ac_cv_host_alias -ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || - { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 -echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} { (exit 1); exit 1; }; } +fi fi -echo "$as_me:$LINENO: result: $ac_cv_target" >&5 -echo "${ECHO_T}$ac_cv_target" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac target=$ac_cv_target -target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. @@ -1417,8 +1927,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1431,32 +1941,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1469,36 +1981,51 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1511,74 +2038,34 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 -fi - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - CC=$ac_ct_CC -else - CC="$ac_cv_prog_CC" -fi + fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1592,7 +2079,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -1603,6 +2090,7 @@ do fi done done +IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. @@ -1620,22 +2108,23 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1648,36 +2137,38 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC - for ac_prog in cl + for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1690,29 +2181,45 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + test -n "$ac_ct_CC" && break done - CC=$ac_ct_CC + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi fi fi @@ -1725,21 +2232,35 @@ See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:$LINENO:" \ - "checking for C compiler version" >&5 +echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 - (eval $ac_compiler --version &5) 2>&5 +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 - (eval $ac_compiler -v &5) 2>&5 +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 - (eval $ac_compiler -V &5) 2>&5 +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } @@ -1764,47 +2285,77 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 - (eval $ac_link_default) 2>&5 +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - # Find the output, starting from the most likely. This scheme is -# not robust to junk in `.', hence go to wildcards (a.*) only as a last -# resort. - -# Be careful to initialize this variable, since it used to be cached. -# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. -ac_cv_exeext= -# b.out is created by i960 compilers. -for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) - ;; - conftest.$ac_ext ) - # This is the source file. + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - # FIXME: I believe we export ac_cv_exeext for Libtool, - # but it would be cool to find out if it's true. Does anybody - # maintain Libtool? --akim. - export ac_cv_exeext + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. break;; * ) break;; esac done +test "$ac_cv_exeext" = no && ac_cv_exeext= + else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -1816,19 +2367,21 @@ See \`config.log' for more details." >&2;} fi ac_exeext=$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6 -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -1847,22 +2400,27 @@ See \`config.log' for more details." >&2;} fi fi fi -echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check the compiler produces executables we can run. If not, either +# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: $cross_compiling" >&5 -echo "${ECHO_T}$cross_compiling" >&6 - -echo "$as_me:$LINENO: checking for suffix of executables" >&5 -echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then @@ -1873,9 +2431,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - export ac_cv_exeext break;; * ) break;; esac @@ -1889,14 +2446,14 @@ See \`config.log' for more details." >&2;} fi rm -f conftest$ac_cv_exeext -echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 -echo "${ECHO_T}$ac_cv_exeext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:$LINENO: checking for suffix of object files" >&5 -echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1916,14 +2473,20 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>&5 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac @@ -1941,12 +2504,12 @@ fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 -echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -1969,50 +2532,49 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_compiler_gnu=no + ac_compiler_gnu=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 -echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" -echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 -echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -2028,38 +2590,118 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_prog_cc_g=no + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag fi -echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then @@ -2075,12 +2717,12 @@ else CFLAGS= fi fi -echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 -echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 -if test "${ac_cv_prog_cc_stdc+set}" = set; then +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - ac_cv_prog_cc_stdc=no + ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2114,12 +2756,17 @@ static char *f (char * (*g) (char **, int), char **p, ...) /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated - as 'x'. The following induces an error, until -std1 is added to get + as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something - that's true only with -std1. */ + that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; @@ -2134,205 +2781,57 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; return 0; } _ACEOF -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX 10.20 and later -Ae -# HP-UX older versions -Aa -D_HPUX_SOURCE -# SVR4 -Xc -D__EXTENSIONS__ -for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - ac_cv_prog_cc_stdc=$ac_arg -break + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break done -rm -f conftest.$ac_ext conftest.$ac_objext +rm -f conftest.$ac_ext CC=$ac_save_CC fi - -case "x$ac_cv_prog_cc_stdc" in - x|xno) - echo "$as_me:$LINENO: result: none needed" >&5 -echo "${ECHO_T}none needed" >&6 ;; +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; *) - echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 -echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 - CC="$CC $ac_cv_prog_cc_stdc" ;; + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac -# Some people use a C++ compiler to compile C. Since we use `exit', -# in C++ we need to declare it. In case someone uses the same compiler -# for both compiling C and C++ we need to have the C++ compiler decide -# the declaration of exit, since it's the most demanding environment. -cat >conftest.$ac_ext <<_ACEOF -#ifndef __cplusplus - choke me -#endif -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - for ac_declaration in \ - '' \ - 'extern "C" void std::exit (int) throw (); using std::exit;' \ - 'extern "C" void std::exit (int); using std::exit;' \ - 'extern "C" void exit (int) throw ();' \ - 'extern "C" void exit (int);' \ - 'void exit (int);' -do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -#include -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -continue -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_declaration -int -main () -{ -exit (42); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - break -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -done -rm -f conftest* -if test -n "$ac_declaration"; then - echo '#ifdef __cplusplus' >>confdefs.h - echo $ac_declaration >>confdefs.h - echo '#endif' >>confdefs.h -fi -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2352,8 +2851,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. -echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 -echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2375,7 +2874,7 @@ case $as_dir/ in # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2394,64 +2893,702 @@ case $as_dir/ in ;; esac done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL=$ac_cv_path_install - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL=$ac_install_sh - fi fi -echo "$as_me:$LINENO: result: $INSTALL" >&5 -echo "${ECHO_T}$INSTALL" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 -echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 -set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` -if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.make <<\_ACEOF -all: - @echo 'ac_maketemp="$(MAKE)"' + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. -eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` -if test -n "$ac_maketemp"; then - eval ac_cv_prog_make_${ac_make}_set=yes +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" else - eval ac_cv_prog_make_${ac_make}_set=no -fi -rm -f conftest.make + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" fi -if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 - SET_MAKE= -else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 - SET_MAKE="MAKE=${MAKE-make}" + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF +fi +done -echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 -echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2468,7 +3605,8 @@ cat >>conftest.$ac_ext <<_ACEOF int main () { -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) bogus endian macros #endif @@ -2477,27 +3615,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2520,40 +3653,36 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -# It does not; compile a test program. + # It does not; compile a test program. if test "$cross_compiling" = yes; then # try to guess the endianness by grepping values into an object file ac_cv_c_bigendian=unknown @@ -2563,11 +3692,11 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; -short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } -short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; -short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } int main () @@ -2578,27 +3707,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi @@ -2614,8 +3738,10 @@ else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 + fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -2623,27 +3749,41 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +$ac_includes_default int main () { + /* Are we little or big endian? From Harbison&Steele. */ union { - long l; - char c[sizeof (long)]; + long int l; + char c[sizeof (long int)]; } u; u.l = 1; - exit (u.c[sizeof (long) - 1] == 1); + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then @@ -2656,13 +3796,16 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_c_bigendian=yes fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi + + fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 -echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in yes) @@ -2683,8 +3826,8 @@ esac # Checks for libraries. -echo "$as_me:$LINENO: checking for cos in -lm" >&5 -echo $ECHO_N "checking for cos in -lm... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for cos in -lm" >&5 +echo $ECHO_N "checking for cos in -lm... $ECHO_C" >&6; } if test "${ac_cv_lib_m_cos+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2697,56 +3840,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char cos (); int main () { -cos (); +return cos (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_m_cos=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_m_cos=no + ac_cv_lib_m_cos=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_m_cos" >&5 -echo "${ECHO_T}$ac_cv_lib_m_cos" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_cos" >&5 +echo "${ECHO_T}$ac_cv_lib_m_cos" >&6; } if test $ac_cv_lib_m_cos = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 @@ -2758,13 +3898,13 @@ fi -# Check whether --with-cet or --without-cet was given. +# Check whether --with-cet was given. if test "${with_cet+set}" = set; then - withval="$with_cet" - cet="$withval" + withval=$with_cet; cet="$withval" else cet="default" -fi; +fi + if test $GCC = yes; then CFLAGS="$CFLAGS -Wall" @@ -2785,107 +3925,109 @@ _ACEOF fi -echo "$as_me:$LINENO: checking whether to support shapefiles" >&5 -echo $ECHO_N "checking whether to support shapefiles... $ECHO_C" >&6 -# Check whether --enable-shapefile or --disable-shapefile was given. +{ echo "$as_me:$LINENO: checking whether to support shapefiles" >&5 +echo $ECHO_N "checking whether to support shapefiles... $ECHO_C" >&6; } +# Check whether --enable-shapefile was given. if test "${enable_shapefile+set}" = set; then - enableval="$enable_shapefile" - enable_shapefile="$enableval" + enableval=$enable_shapefile; enable_shapefile="$enableval" else enable_shapefile="yes" -fi; +fi + if test "$enable_shapefile" != "no" ; then cat >>confdefs.h <<\_ACEOF #define SHAPELIB_ENABLED 1 _ACEOF - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi -echo "$as_me:$LINENO: checking whether to support Palm/OS pdb formats" >&5 -echo $ECHO_N "checking whether to support Palm/OS pdb formats... $ECHO_C" >&6 -# Check whether --enable-pdb or --disable-pdb was given. +{ echo "$as_me:$LINENO: checking whether to support Palm/OS pdb formats" >&5 +echo $ECHO_N "checking whether to support Palm/OS pdb formats... $ECHO_C" >&6; } +# Check whether --enable-pdb was given. if test "${enable_pdb+set}" = set; then - enableval="$enable_pdb" - enable_pdb="$enableval" + enableval=$enable_pdb; enable_pdb="$enableval" else enable_pdb="yes" -fi; +fi + if test "$enable_pdb" != "no" ; then cat >>confdefs.h <<\_ACEOF #define PDBFMTS_ENABLED 1 _ACEOF - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + PALM_DB_CMT=# + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi -echo "$as_me:$LINENO: checking whether to support csv formats" >&5 -echo $ECHO_N "checking whether to support csv formats... $ECHO_C" >&6 -# Check whether --enable-csv or --disable-csv was given. + +{ echo "$as_me:$LINENO: checking whether to support csv formats" >&5 +echo $ECHO_N "checking whether to support csv formats... $ECHO_C" >&6; } +# Check whether --enable-csv was given. if test "${enable_csv+set}" = set; then - enableval="$enable_csv" - enable_csv="$enableval" + enableval=$enable_csv; enable_csv="$enableval" else enable_csv="yes" -fi; +fi + if test "$enable_csv" != "no" ; then cat >>confdefs.h <<\_ACEOF #define CSVFMTS_ENABLED 1 _ACEOF - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi -echo "$as_me:$LINENO: checking whether to support filters" >&5 -echo $ECHO_N "checking whether to support filters... $ECHO_C" >&6 -# Check whether --enable-filters or --disable-filters was given. +{ echo "$as_me:$LINENO: checking whether to support filters" >&5 +echo $ECHO_N "checking whether to support filters... $ECHO_C" >&6; } +# Check whether --enable-filters was given. if test "${enable_filters+set}" = set; then - enableval="$enable_filters" - enable_filters="$enableval" + enableval=$enable_filters; enable_filters="$enableval" else enable_filters="yes" -fi; +fi + if test "$enable_filters" != "no" ; then cat >>confdefs.h <<\_ACEOF #define FILTERS_ENABLED 1 _ACEOF - echo "$as_me:$LINENO: result: yes" >&5 -echo "${ECHO_T}yes" >&6 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi -echo "$as_me:$LINENO: checking whether to support zlib" >&5 -echo $ECHO_N "checking whether to support zlib... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking whether to support zlib" >&5 +echo $ECHO_N "checking whether to support zlib... $ECHO_C" >&6; } -# Check whether --with-zlib or --without-zlib was given. +# Check whether --with-zlib was given. if test "${with_zlib+set}" = set; then - withval="$with_zlib" + withval=$with_zlib; +fi -fi; case $with_zlib in "system") -echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 -echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 +echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6; } if test "${ac_cv_lib_z_gzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -2898,56 +4040,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char gzopen (); int main () { -gzopen (); +return gzopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_z_gzopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_z_gzopen=no + ac_cv_lib_z_gzopen=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 -echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 +echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6; } if test $ac_cv_lib_z_gzopen = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 @@ -2964,12 +4103,12 @@ cat >>confdefs.h <<\_ACEOF #define ZLIB_INHIBITED 1 _ACEOF - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } ;; *) ZLIB="\$(ZLIB)" - echo "$as_me:$LINENO: result: using included version" >&5 -echo "${ECHO_T}using included version" >&6;; + { echo "$as_me:$LINENO: result: using included version" >&5 +echo "${ECHO_T}using included version" >&6; };; esac case "$target" in @@ -2994,8 +4133,8 @@ case "$target" in GBSER=gbser_win.o if test "$with_libusb" = no ; then - echo "$as_me:$LINENO: result: USB skipped" >&5 -echo "${ECHO_T}USB skipped" >&6 + { echo "$as_me:$LINENO: result: USB skipped" >&5 +echo "${ECHO_T}USB skipped" >&6; } OSJEEPS=jeeps/gpsusbstub.o else OSJEEPS=jeeps/gpsusbwin.o @@ -3004,17 +4143,17 @@ echo "${ECHO_T}USB skipped" >&6 ;; *) GBSER=gbser_posix.o - echo "$as_me:$LINENO: checking for libusb" >&5 -echo $ECHO_N "checking for libusb... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for libusb" >&5 +echo $ECHO_N "checking for libusb... $ECHO_C" >&6; } if test "$with_libusb" = no ; then - echo "$as_me:$LINENO: result: check not done" >&5 -echo "${ECHO_T}check not done" >&6 + { echo "$as_me:$LINENO: result: check not done" >&5 +echo "${ECHO_T}check not done" >&6; } OSJEEPS=jeeps/gpsusbstub.o else # Extract the first word of "libusb-config", so it can be a program name with args. set dummy libusb-config; ac_word=$2 -echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_LIBUSBCONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3027,34 +4166,36 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIBUSBCONFIG="true" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done +IFS=$as_save_IFS test -z "$ac_cv_prog_LIBUSBCONFIG" && ac_cv_prog_LIBUSBCONFIG="false" fi fi LIBUSBCONFIG=$ac_cv_prog_LIBUSBCONFIG if test -n "$LIBUSBCONFIG"; then - echo "$as_me:$LINENO: result: $LIBUSBCONFIG" >&5 -echo "${ECHO_T}$LIBUSBCONFIG" >&6 + { echo "$as_me:$LINENO: result: $LIBUSBCONFIG" >&5 +echo "${ECHO_T}$LIBUSBCONFIG" >&6; } else - echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6 + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi + if test "$LIBUSBCONFIG" = true; then OLDFLAGS=$LDFLAGS OCFLAGS=$CFLAGS LDFLAGS="$LDFLAGS `libusb-config --libs`" CFLAGS="$OCFLAGS `libusb-config --cflags`" - echo "$as_me:$LINENO: checking for usb_interrupt_read in -lusb" >&5 -echo $ECHO_N "checking for usb_interrupt_read in -lusb... $ECHO_C" >&6 + { echo "$as_me:$LINENO: checking for usb_interrupt_read in -lusb" >&5 +echo $ECHO_N "checking for usb_interrupt_read in -lusb... $ECHO_C" >&6; } if test "${ac_cv_lib_usb_usb_interrupt_read+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3067,56 +4208,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char usb_interrupt_read (); int main () { -usb_interrupt_read (); +return usb_interrupt_read (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_usb_usb_interrupt_read=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_usb_usb_interrupt_read=no + ac_cv_lib_usb_usb_interrupt_read=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 -echo "${ECHO_T}$ac_cv_lib_usb_usb_interrupt_read" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_usb_usb_interrupt_read" >&5 +echo "${ECHO_T}$ac_cv_lib_usb_usb_interrupt_read" >&6; } if test $ac_cv_lib_usb_usb_interrupt_read = yes; then cat >>confdefs.h <<\_ACEOF @@ -3155,16 +4293,15 @@ esac -echo "$as_me:$LINENO: checking for random stuff to make you feel better" >&5 -echo $ECHO_N "checking for random stuff to make you feel better... $ECHO_C" >&6 -echo "$as_me:$LINENO: result: failed" >&5 -echo "${ECHO_T}failed" >&6 +{ echo "$as_me:$LINENO: checking for random stuff to make you feel better" >&5 +echo $ECHO_N "checking for random stuff to make you feel better... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6; } -# Check whether --with-expathdr or --without-expathdr was given. +# Check whether --with-expathdr was given. if test "${with_expathdr+set}" = set; then - withval="$with_expathdr" - xpathdr="$withval" + withval=$with_expathdr; xpathdr="$withval" else case "$target" in @@ -3182,19 +4319,19 @@ else esac -fi; +fi + if test "x-$xpathdr" != "x-" ; then CFLAGS="$CFLAGS -I$xpathdr" fi -echo "$as_me:$LINENO: checking for libexpat" >&5 -echo $ECHO_N "checking for libexpat... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for libexpat" >&5 +echo $ECHO_N "checking for libexpat... $ECHO_C" >&6; } -# Check whether --with-libexpat or --without-libexpat was given. +# Check whether --with-libexpat was given. if test "${with_libexpat+set}" = set; then - withval="$with_libexpat" - CFLAGS="$CFLAGS -L$withval" + withval=$with_libexpat; CFLAGS="$CFLAGS -L$withval" EXPAT_LIB="-L$withval -lexpat" else @@ -3228,12 +4365,13 @@ _ACEOF esac -fi; -echo "$as_me:$LINENO: result: $EXPAT_LIB" >&5 -echo "${ECHO_T}$EXPAT_LIB" >&6 +fi + +{ echo "$as_me:$LINENO: result: $EXPAT_LIB" >&5 +echo "${ECHO_T}$EXPAT_LIB" >&6; } -echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5 -echo $ECHO_N "checking for XML_ParserCreate in -lexpat... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5 +echo $ECHO_N "checking for XML_ParserCreate in -lexpat... $ECHO_C" >&6; } if test "${ac_cv_lib_expat_XML_ParserCreate+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else @@ -3246,56 +4384,53 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char XML_ParserCreate (); int main () { -XML_ParserCreate (); +return XML_ParserCreate (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_expat_XML_ParserCreate=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -ac_cv_lib_expat_XML_ParserCreate=no + ac_cv_lib_expat_XML_ParserCreate=no fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:$LINENO: result: $ac_cv_lib_expat_XML_ParserCreate" >&5 -echo "${ECHO_T}$ac_cv_lib_expat_XML_ParserCreate" >&6 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_expat_XML_ParserCreate" >&5 +echo "${ECHO_T}$ac_cv_lib_expat_XML_ParserCreate" >&6; } if test $ac_cv_lib_expat_XML_ParserCreate = yes; then cat >>confdefs.h <<\_ACEOF @@ -3307,33 +4442,33 @@ _ACEOF fi -echo "$as_me:$LINENO: checking for efence" >&5 -echo $ECHO_N "checking for efence... $ECHO_C" >&6 -# Check whether --enable-efence or --disable-efence was given. +{ echo "$as_me:$LINENO: checking for efence" >&5 +echo $ECHO_N "checking for efence... $ECHO_C" >&6; } +# Check whether --enable-efence was given. if test "${enable_efence+set}" = set; then - enableval="$enable_efence" - if test "$enable_efence" != "no" ; then + enableval=$enable_efence; if test "$enable_efence" != "no" ; then EFENCE_LIB=-lefence GPSBABEL_DEBUG=gpsbabel-debug INSTALL_DEBUG=install-debug fi -fi; +fi + -echo "$as_me:$LINENO: result: $EFENCE_LIB" >&5 -echo "${ECHO_T}$EFENCE_LIB" >&6 +{ echo "$as_me:$LINENO: result: $EFENCE_LIB" >&5 +echo "${ECHO_T}$EFENCE_LIB" >&6; } -echo "$as_me:$LINENO: checking for docdir" >&5 -echo $ECHO_N "checking for docdir... $ECHO_C" >&6 +{ echo "$as_me:$LINENO: checking for docdir" >&5 +echo $ECHO_N "checking for docdir... $ECHO_C" >&6; } -# Check whether --with-doc or --without-doc was given. +# Check whether --with-doc was given. if test "${with_doc+set}" = set; then - withval="$with_doc" - DOCDIR="$withval" + withval=$with_doc; DOCDIR="$withval" else DOCDIR="../babelweb/" -fi; +fi + # Checks for header files. @@ -3365,9 +4500,9 @@ fi; for ac_func in nanosleep sleep do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 -if eval "test \"\${$as_ac_var+set}\" = set"; then +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -3393,68 +4528,60 @@ cat >>conftest.$ac_ext <<_ACEOF #undef $ac_func -/* Override any gcc2 internal prototype to avoid an error. */ +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" -{ #endif -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +#if defined __stub_$ac_func || defined __stub___$ac_func choke me -#else -char (*f) () = $ac_func; -#endif -#ifdef __cplusplus -} #endif int main () { -return f != $ac_func; +return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>conftest.er1 +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" - || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -eval "$as_ac_var=no" + eval "$as_ac_var=no" fi -rm -f conftest.err conftest.$ac_objext \ + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 -echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 @@ -3464,7 +4591,7 @@ fi done - ac_config_files="$ac_config_files Makefile gbversion.h xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc coldsync/Makefile jeeps/Makefile shapelib/Makefile zlib/empty" +ac_config_files="$ac_config_files Makefile gbversion.h xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -3484,39 +4611,58 @@ _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. +# So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. -{ +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; + ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n \ - "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; - esac; -} | + esac | + sort +) | sed ' + /^ac_cv_env_/b end t clear - : clear + :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end - /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - : end' >>confcache -if diff $cache_file confcache >/dev/null 2>&1; then :; else - if test -w $cache_file; then - test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - echo "not updating unwritable cache $cache_file" + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache @@ -3525,32 +4671,18 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/; -s/:*\${srcdir}:*/:/; -s/:*@srcdir@:*/:/; -s/^\([^=]*=[ ]*\):*/\1/; -s/:*$//; -s/^[^=]*=[ ]*$//; -}' -fi - DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. - ac_i=`echo "$ac_i" | - sed 's/\$U\././;s/\.o$//;s/\.obj$//'` - # 2. Add them. - ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -3581,17 +4713,45 @@ cat >>$CONFIG_STATUS <<\_ACEOF ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' -elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then - set -o posix + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh fi -DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then @@ -3601,8 +4761,43 @@ else fi +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + # Work around bugs in pre-3.0 UWIN ksh. -$as_unset ENV MAIL MAILPATH +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done PS1='$ ' PS2='> ' PS4='+ ' @@ -3616,178 +4811,140 @@ do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else - $as_unset $as_var + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi - -if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - - -# Name of the executable. -as_me=`$as_basename "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)$' \| \ - . : '\(.\)' 2>/dev/null || -echo X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } - /^X\/\(\/\/\)$/{ s//\1/; q; } - /^X\/\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - - -# PATH needs CR, and LINENO needs CR and PATH. -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - echo "#! /bin/sh" >conf$$.sh - echo "exit 0" >>conf$$.sh - chmod +x conf$$.sh - if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then - PATH_SEPARATOR=';' - else - PATH_SEPARATOR=: - fi - rm -f conf$$.sh + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false fi - as_lineno_1=$LINENO - as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" || { - # Find who we are. Look in the path if we contain no path at all - # relative or not. - case $0 in - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + - ;; - esac - # We did not find ourselves, most probably we were run as `sh COMMAND' - # in which case we are not to be found in the path. - if test "x$as_myself" = x; then - as_myself=$0 - fi - if test ! -f "$as_myself"; then - { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 -echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} - { (exit 1); exit 1; }; } - fi - case $CONFIG_SHELL in - '') - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for as_base in sh bash ksh sh5; do - case $as_dir in - /*) - if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO - as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && - test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then - $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } - $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } - CONFIG_SHELL=$as_dir/$as_base - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$0" ${1+"$@"} - fi;; - esac - done -done -;; - esac + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line before each line; the second 'sed' does the real - # work. The second script uses 'N' to pair each line-number line - # with the numbered line, and appends trailing '-' during - # substitution so that $LINENO is not a special case at line end. + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) - sed '=' <$as_myself | + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno N - s,$,-, - : loop - s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop - s,-$,, - s,^['$as_cr_digits']*\n,, + s/-\n.*// ' >$as_me.lineno && - chmod +x $as_me.lineno || - { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 -echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensible to this). - . ./$as_me.lineno + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" # Exit status is that of the last command. exit } -case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in - *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; - *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; - *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1; then +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then - # We could just check for DJGPP; but this test a) works b) is more generic - # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). - if test -f conf$$.exe; then - # Don't use ln at all; we don't have any links + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' - else - as_ln_s='ln -s' - fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi -rm -f conf$$ conf$$.exe conf$$.file +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: @@ -3796,7 +4953,28 @@ else as_mkdir_p=false fi -as_executable_p="test -f" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -3805,31 +4983,14 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -# IFS -# We need space, tab and new line, in precisely that order. -as_nl=' -' -IFS=" $as_nl" - -# CDPATH. -$as_unset CDPATH - exec 6>&1 -# Open the log real soon, to keep \$[0] and so on meaningful, and to +# Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. Logging --version etc. is OK. -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX -} >&5 -cat >&5 <<_CSEOF - -This file was extended by GPSBabel $as_me 1.3.3, which was -generated by GNU Autoconf 2.59. Invocation command line was +# values after options handling. +ac_log=" +This file was extended by GPSBabel $as_me 1.3.4, which was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3837,30 +4998,19 @@ generated by GNU Autoconf 2.59. Invocation command line was CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ -_CSEOF -echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 -echo >&5 +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + _ACEOF +cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. -if test -n "$ac_config_files"; then - echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_headers"; then - echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS -fi - -if test -n "$ac_config_links"; then - echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS -fi +config_files="$ac_config_files" +config_headers="$ac_config_headers" -if test -n "$ac_config_commands"; then - echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS -fi +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF - ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. @@ -3868,7 +5018,7 @@ current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -3884,19 +5034,21 @@ Configuration headers: $config_headers Report bugs to ." -_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -GPSBabel config.status 1.3.3 -configured by $0, generated by GNU Autoconf 2.59, - with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" +GPSBabel config.status 1.3.4 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -Copyright (C) 2003 Free Software Foundation, Inc. +Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir -INSTALL="$INSTALL" + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF @@ -3907,39 +5059,24 @@ while test $# != 0 do case $1 in --*=*) - ac_option=`expr "x$1" : 'x\([^=]*\)='` - ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; - -*) + *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; - *) # This is not an option, so the user has probably given explicit - # arguments. - ac_option=$1 - ac_need_defaults=false;; esac case $ac_option in # Handling of the options. -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; - --version | --vers* | -V ) - echo "$ac_cs_version"; exit 0 ;; - --he | --h) - # Conflict between --help and --header - { { echo "$as_me:$LINENO: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2;} - { (exit 1); exit 1; }; };; - --help | --hel | -h ) - echo "$ac_cs_usage"; exit 0 ;; - --debug | --d* | -d ) + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift @@ -3949,18 +5086,24 @@ Try \`$0 --help' for more information." >&2;} $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. - -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&5 -echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2;} + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; - *) ac_config_targets="$ac_config_targets $1" ;; + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; esac shift @@ -3976,37 +5119,50 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then - echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 - exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 - - - +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. for ac_config_target in $ac_config_targets do - case "$ac_config_target" in - # Handling of arguments. - "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "gbversion.h" ) CONFIG_FILES="$CONFIG_FILES gbversion.h" ;; - "xmldoc/makedoc" ) CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;; - "tools/mkcapabilities" ) CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;; - "win32/gpsbabel.rc" ) CONFIG_FILES="$CONFIG_FILES win32/gpsbabel.rc" ;; - "coldsync/Makefile" ) CONFIG_FILES="$CONFIG_FILES coldsync/Makefile" ;; - "jeeps/Makefile" ) CONFIG_FILES="$CONFIG_FILES jeeps/Makefile" ;; - "shapelib/Makefile" ) CONFIG_FILES="$CONFIG_FILES shapelib/Makefile" ;; - "zlib/empty" ) CONFIG_FILES="$CONFIG_FILES zlib/empty" ;; - "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "gbversion.h") CONFIG_FILES="$CONFIG_FILES gbversion.h" ;; + "xmldoc/makedoc") CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;; + "tools/mkcapabilities") CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;; + "win32/gpsbabel.rc") CONFIG_FILES="$CONFIG_FILES win32/gpsbabel.rc" ;; + "jeeps/Makefile") CONFIG_FILES="$CONFIG_FILES jeeps/Makefile" ;; + "shapelib/Makefile") CONFIG_FILES="$CONFIG_FILES shapelib/Makefile" ;; + "zlib/empty") CONFIG_FILES="$CONFIG_FILES zlib/empty" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done + # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely @@ -4017,326 +5173,397 @@ if $ac_need_defaults; then fi # Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason to put it here, and in addition, +# simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. -# Create a temporary directory, and hook for its removal unless debugging. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. $debug || { - trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } - # Create a (secure) tmp directory for tmp files. { - tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { - tmp=./confstat$$-$RANDOM - (umask 077 && mkdir $tmp) + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } -_ACEOF - -cat >>$CONFIG_STATUS <<_ACEOF - # -# CONFIG_FILES section. +# Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h -if test -n "\$CONFIG_FILES"; then - # Protect against being on the right side of a sed subst in config.status. - sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; - s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF -s,@SHELL@,$SHELL,;t t -s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t -s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t -s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t -s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t -s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t -s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t -s,@exec_prefix@,$exec_prefix,;t t -s,@prefix@,$prefix,;t t -s,@program_transform_name@,$program_transform_name,;t t -s,@bindir@,$bindir,;t t -s,@sbindir@,$sbindir,;t t -s,@libexecdir@,$libexecdir,;t t -s,@datadir@,$datadir,;t t -s,@sysconfdir@,$sysconfdir,;t t -s,@sharedstatedir@,$sharedstatedir,;t t -s,@localstatedir@,$localstatedir,;t t -s,@libdir@,$libdir,;t t -s,@includedir@,$includedir,;t t -s,@oldincludedir@,$oldincludedir,;t t -s,@infodir@,$infodir,;t t -s,@mandir@,$mandir,;t t -s,@build_alias@,$build_alias,;t t -s,@host_alias@,$host_alias,;t t -s,@target_alias@,$target_alias,;t t -s,@DEFS@,$DEFS,;t t -s,@ECHO_C@,$ECHO_C,;t t -s,@ECHO_N@,$ECHO_N,;t t -s,@ECHO_T@,$ECHO_T,;t t -s,@LIBS@,$LIBS,;t t -s,@PACKAGE_RELEASE@,$PACKAGE_RELEASE,;t t -s,@GBMAJOR@,$GBMAJOR,;t t -s,@GBMINOR@,$GBMINOR,;t t -s,@GBMICRO@,$GBMICRO,;t t -s,@build@,$build,;t t -s,@build_cpu@,$build_cpu,;t t -s,@build_vendor@,$build_vendor,;t t -s,@build_os@,$build_os,;t t -s,@host@,$host,;t t -s,@host_cpu@,$host_cpu,;t t -s,@host_vendor@,$host_vendor,;t t -s,@host_os@,$host_os,;t t -s,@target@,$target,;t t -s,@target_cpu@,$target_cpu,;t t -s,@target_vendor@,$target_vendor,;t t -s,@target_os@,$target_os,;t t -s,@CC@,$CC,;t t -s,@CFLAGS@,$CFLAGS,;t t -s,@LDFLAGS@,$LDFLAGS,;t t -s,@CPPFLAGS@,$CPPFLAGS,;t t -s,@ac_ct_CC@,$ac_ct_CC,;t t -s,@EXEEXT@,$EXEEXT,;t t -s,@OBJEXT@,$OBJEXT,;t t -s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t -s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t -s,@INSTALL_DATA@,$INSTALL_DATA,;t t -s,@SET_MAKE@,$SET_MAKE,;t t -s,@FILEINFO@,$FILEINFO,;t t -s,@RC@,$RC,;t t -s,@LIBUSBCONFIG@,$LIBUSBCONFIG,;t t -s,@USB_LIBS@,$USB_LIBS,;t t -s,@USB_CFLAGS@,$USB_CFLAGS,;t t -s,@OSJEEPS@,$OSJEEPS,;t t -s,@GBSER@,$GBSER,;t t -s,@ZLIB@,$ZLIB,;t t -s,@EXPAT_LIB@,$EXPAT_LIB,;t t -s,@EFENCE_LIB@,$EFENCE_LIB,;t t -s,@GPSBABEL_DEBUG@,$GPSBABEL_DEBUG,;t t -s,@INSTALL_DEBUG@,$INSTALL_DEBUG,;t t -s,@DOCDIR@,$DOCDIR,;t t -s,@LIBOBJS@,$LIBOBJS,;t t -s,@LTLIBOBJS@,$LTLIBOBJS,;t t -CEOF +if test -n "$CONFIG_FILES"; then _ACEOF - cat >>$CONFIG_STATUS <<\_ACEOF - # Split the substitutions into bite-sized pieces for seds with - # small command number limits, like on Digital OSF/1 and HP-UX. - ac_max_sed_lines=48 - ac_sed_frag=1 # Number of current file. - ac_beg=1 # First line for current file. - ac_end=$ac_max_sed_lines # Line after last line for current file. - ac_more_lines=: - ac_sed_cmds= - while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - else - sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag - fi - if test ! -s $tmp/subs.frag; then - ac_more_lines=false - else - # The purpose of the label and of the branching condition is to - # speed up the sed processing (if there are no `@' at all, there - # is no need to browse any of the substitutions). - # These are the two extra sed commands mentioned above. - (echo ':t - /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" - else - ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" - fi - ac_sed_frag=`expr $ac_sed_frag + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_lines` - fi - done - if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +PACKAGE_RELEASE!$PACKAGE_RELEASE$ac_delim +GBMAJOR!$GBMAJOR$ac_delim +GBMINOR!$GBMINOR$ac_delim +GBMICRO!$GBMICRO$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +PALM_DB_CMT!$PALM_DB_CMT$ac_delim +FILEINFO!$FILEINFO$ac_delim +RC!$RC$ac_delim +LIBUSBCONFIG!$LIBUSBCONFIG$ac_delim +USB_LIBS!$USB_LIBS$ac_delim +USB_CFLAGS!$USB_CFLAGS$ac_delim +OSJEEPS!$OSJEEPS$ac_delim +GBSER!$GBSER$ac_delim +ZLIB!$ZLIB$ac_delim +EXPAT_LIB!$EXPAT_LIB$ac_delim +EFENCE_LIB!$EFENCE_LIB$ac_delim +GPSBABEL_DEBUG!$GPSBABEL_DEBUG$ac_delim +INSTALL_DEBUG!$INSTALL_DEBUG$ac_delim +DOCDIR!$DOCDIR$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 83; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi -fi # test -n "$CONFIG_FILES" +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + cat >>$CONFIG_STATUS <<\_ACEOF -for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; esac - # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. - ac_dir=`(dirname "$ac_file") 2>/dev/null || + ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } - ac_builddir=. -if test "$ac_dir" != .; then +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` - # A "../" for each directory in $ac_dir_suffix. - ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` -else - ac_dir_suffix= ac_top_builddir= -fi + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix case $srcdir in - .) # No --srcdir option. We are building in place. + .) # We are building in place. ac_srcdir=. - if test -z "$ac_top_builddir"; then - ac_top_srcdir=. - else - ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` - fi ;; - [\\/]* | ?:[\\/]* ) # Absolute path. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir ;; - *) # Relative path. - ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_builddir$srcdir ;; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix -# Do not use `cd foo && pwd` to compute absolute paths, because -# the directories may not exist. -case `pwd` in -.) ac_abs_builddir="$ac_dir";; -*) - case "$ac_dir" in - .) ac_abs_builddir=`pwd`;; - [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; - *) ac_abs_builddir=`pwd`/"$ac_dir";; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_builddir=${ac_top_builddir}.;; -*) - case ${ac_top_builddir}. in - .) ac_abs_top_builddir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; - *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_srcdir=$ac_srcdir;; -*) - case $ac_srcdir in - .) ac_abs_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; - *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; - esac;; -esac -case $ac_abs_builddir in -.) ac_abs_top_srcdir=$ac_top_srcdir;; -*) - case $ac_top_srcdir in - .) ac_abs_top_srcdir=$ac_abs_builddir;; - [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; - *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; - esac;; -esac + case $ac_mode in + :F) + # + # CONFIG_FILE + # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac +_ACEOF - if test x"$ac_file" != x-; then - { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - rm -f "$ac_file" - fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - configure_input= - else - configure_input="$ac_file. " - fi - configure_input=$configure_input"Generated from `echo $ac_file_in | - sed 's,.*/,,'` by configure." - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac _ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub @@ -4344,252 +5571,137 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t -s,@INSTALL@,$ac_INSTALL,;t t -" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out - rm -f $tmp/stdin - if test x"$ac_file" != x-; then - mv $tmp/out $ac_file - else - cat $tmp/out - rm -f $tmp/out - fi - -done -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF - -# -# CONFIG_HEADER section. -# - -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='[ ].*$,\1#\2' -ac_dC=' ' -ac_dD=',;t' -# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='$,\1#\2define\3' -ac_uC=' ' -ac_uD=',;t' - -for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" case $ac_file in - - | *:- | *:-:* ) # input from stdin - cat >$tmp/stdin - ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` - ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; - * ) ac_file_in=$ac_file.in ;; + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac - - test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 -echo "$as_me: creating $ac_file" >&6;} - - # First look for the input files in the build tree, otherwise in the - # src tree. - ac_file_inputs=`IFS=: - for f in $ac_file_in; do - case $f in - -) echo $tmp/stdin ;; - [\\/$]*) - # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - # Do quote $f, to prevent DOS paths from being IFS'd. - echo "$f";; - *) # Relative - if test -f "$f"; then - # Build tree - echo "$f" - elif test -f "$srcdir/$f"; then - # Source tree - echo "$srcdir/$f" - else - # /dev/null tree - { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 -echo "$as_me: error: cannot find input file: $f" >&2;} - { (exit 1); exit 1; }; } - fi;; - esac - done` || { (exit 1); exit 1; } - # Remove the trailing spaces. - sed 's/[ ]*$//' $ac_file_inputs >$tmp/in - + ;; + :H) + # + # CONFIG_HEADER + # _ACEOF -# Transform confdefs.h into two sed scripts, `conftest.defines' and -# `conftest.undefs', that substitutes the proper values into -# config.h.in to produce config.h. The first handles `#define' -# templates, and the second `#undef' templates. -# And first: Protect against being on the right side of a sed subst in -# config.status. Protect against being in an unquoted here document -# in config.status. -rm -f conftest.defines conftest.undefs -# Using a here document instead of a string reduces the quoting nightmare. -# Putting comments in sed scripts is not portable. -# -# `end' is used to avoid that the second main sed command (meant for -# 0-ary CPP macros) applies to n-ary macro definitions. -# See the Autoconf documentation for `clear'. -cat >confdef2sed.sed <<\_ACEOF -s/[\\&,]/\\&/g -s,[\\$`],\\&,g -t clear -: clear -s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp -t end -s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp -: end -_ACEOF -# If some macros were called several times there might be several times -# the same #defines, which is useless. Nevertheless, we may not want to -# sort them, since we want the *last* AC-DEFINE to be honored. -uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines -sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs -rm -f confdef2sed.sed - -# This sed command replaces #undef with comments. This is necessary, for +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. -cat >>conftest.undefs <<\_ACEOF -s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, -_ACEOF - -# Break up conftest.defines because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS -echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS -echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS -echo ' :' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.defines >/dev/null +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : do - # Write a limited-size here document to $tmp/defines.sed. - echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#define' lines. - echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF - sed -f $tmp/defines.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done -rm -f conftest.defines -echo ' fi # grep' >>$CONFIG_STATUS -echo >>$CONFIG_STATUS - -# Break up conftest.undefs because some shells have a limit on the size -# of here documents, and old seds have small limits too (100 cmds). -echo ' # Handle all the #undef templates' >>$CONFIG_STATUS -rm -f conftest.tail -while grep . conftest.undefs >/dev/null -do - # Write a limited-size here document to $tmp/undefs.sed. - echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS - # Speed up: don't consider the non `#undef' - echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS - # Work around the forget-to-reset-the-flag bug. - echo 't clr' >>$CONFIG_STATUS - echo ': clr' >>$CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS - echo 'CEOF - sed -f $tmp/undefs.sed $tmp/in >$tmp/out - rm -f $tmp/in - mv $tmp/out $tmp/in -' >>$CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail - rm -f conftest.undefs - mv conftest.tail conftest.undefs -done -rm -f conftest.undefs +rm -f conftest.defines conftest.tail +echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - if test x"$ac_file" = x-; then - echo "/* Generated by configure. */" >$tmp/config.h - else - echo "/* $ac_file. Generated by configure. */" >$tmp/config.h - fi - cat $tmp/in >>$tmp/config.h - rm -f $tmp/in if test x"$ac_file" != x-; then - if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else - ac_dir=`(dirname "$ac_file") 2>/dev/null || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - { if $as_mkdir_p; then - mkdir -p "$ac_dir" - else - as_dir="$ac_dir" - as_dirs= - while test ! -d "$as_dir"; do - as_dirs="$as_dir $as_dirs" - as_dir=`(dirname "$as_dir") 2>/dev/null || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| \ - . : '\(.\)' 2>/dev/null || -echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } - /^X\(\/\/\)[^/].*/{ s//\1/; q; } - /^X\(\/\/\)$/{ s//\1/; q; } - /^X\(\/\).*/{ s//\1/; q; } - s/.*/./; q'` - done - test ! -n "$as_dirs" || mkdir $as_dirs - fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 -echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} - { (exit 1); exit 1; }; }; } - rm -f $ac_file - mv $tmp/config.h $ac_file + mv "$tmp/config.h" $ac_file fi else - cat $tmp/config.h - rm -f $tmp/config.h + echo "/* $configure_input */" + cat "$ac_result" fi -done -_ACEOF + rm -f "$tmp/out12" + ;; + + + esac + +done # for ac_tag -cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF diff --git a/configure.in b/configure.in index 39ce49bff..8cf8cf5e9 100644 --- a/configure.in +++ b/configure.in @@ -3,10 +3,10 @@ AC_PREREQ(2.59) -AC_INIT(GPSBabel, 1.3.3, BUG-REPORT-ADDRESS) +AC_INIT(GPSBabel, 1.3.4, BUG-REPORT-ADDRESS) # YYYYMMDD, please, if beta, i.e. "-beta20060413" -# PACKAGE_RELEASE="-beta20061125" +# PACKAGE_RELEASE="-beta20070711" AC_DEFINE_UNQUOTED(PACKAGE_RELEASE, "$PACKAGE_RELEASE", [Define to the release name of this package.]) AC_SUBST(PACKAGE_RELEASE) @@ -68,8 +68,10 @@ AC_ARG_ENABLE(pdb, AC_DEFINE(PDBFMTS_ENABLED, 1, [1 to enable Palm PDB support]) AC_MSG_RESULT(yes) else + PALM_DB_CMT=# AC_MSG_RESULT(no) fi +AC_SUBST(PALM_DB_CMT) AC_MSG_CHECKING(whether to support csv formats) AC_ARG_ENABLE(csv, @@ -286,5 +288,5 @@ AC_SUBST(DOCDIR) # AC_CHECK_FUNCS([atexit floor localtime_r memmove memset pow select sqrt strchr strcspn strdup strerror strncasecmp strrchr strspn strstr strtol strtoul]) AC_CHECK_FUNCS([nanosleep sleep]) -AC_CONFIG_FILES([Makefile gbversion.h xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc coldsync/Makefile jeeps/Makefile shapelib/Makefile zlib/empty]) +AC_CONFIG_FILES([Makefile gbversion.h xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc jeeps/Makefile shapelib/Makefile zlib/empty]) AC_OUTPUT diff --git a/copilot.c b/copilot.c index 98725740e..9405b9723 100644 --- a/copilot.c +++ b/copilot.c @@ -21,8 +21,7 @@ #include "defs.h" #if PDBFMTS_ENABLED -#include "coldsync/palm.h" -#include "coldsync/pdb.h" +#include "pdbfile.h" #include "grtcirc.h" #define MYNAME "CoPilot Waypoint" @@ -37,7 +36,7 @@ struct record0 { pdb_double latitude; /* PDB double format, */ pdb_double longitude; /* similarly, neg = east */ pdb_double magvar; /* magnetic variation in degrees, neg = east */ - udword elevation; /* feet */ + gbuint32 elevation; /* feet */ }; struct record1 { @@ -62,39 +61,38 @@ struct record4 { pdb_float elevation; /* feet */ }; -static FILE *file_in; -static FILE *file_out; +static pdbfile *file_in, *file_out; static const char *out_fname; -static struct pdb *opdb; -static struct pdb_record *opdb_rec; +static int ct; static void rd_init(const char *fname) { - file_in = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); } static void rd_deinit(void) { - fclose(file_in); + pdb_close(file_in); } static void wr_init(const char *fname) { - file_out = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); out_fname = fname; + ct = 0; } static void wr_deinit(void) { - fclose(file_out); + pdb_close(file_out); } static waypoint* -read_version0(ubyte* data) +read_version0(void *data) { char *vdata; waypoint *wpt_tmp; @@ -122,7 +120,7 @@ read_version0(ubyte* data) } static waypoint* -read_version1(ubyte* data) +read_version1(void *data) { char *vdata; waypoint *wpt_tmp; @@ -151,7 +149,7 @@ read_version1(ubyte* data) } static waypoint* -read_version3(ubyte* data) +read_version3(void *data) { char *vdata; waypoint *wpt_tmp; @@ -180,7 +178,7 @@ read_version3(ubyte* data) } static waypoint* -read_version4(ubyte* data) +read_version4(void *data) { char *vdata; waypoint *wpt_tmp; @@ -211,27 +209,22 @@ read_version4(ubyte* data) static void data_read(void) { - struct pdb *pdb; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; - if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed\n"); - } - - if ((pdb->creator != GXPU_CREATOR && pdb->creator != AP_P_CREATOR) || - (pdb->type != wayp_TYPE && pdb->type != swpu_TYPE && - pdb->type != wayu_TYPE)) { + if ((file_in->creator != GXPU_CREATOR && file_in->creator != AP_P_CREATOR) || + (file_in->type != wayp_TYPE && file_in->type != swpu_TYPE && + file_in->type != wayu_TYPE)) { fatal(MYNAME ": Not a CoPilot file.\n"); } - if (pdb->version > 4) { - fatal(MYNAME ": %d is not a known version.\n", pdb->version); + if (file_in->version > 4) { + fatal(MYNAME ": %d is not a known version.\n", file_in->version); } - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) { + for(pdb_rec = file_in->rec_list; pdb_rec; pdb_rec = pdb_rec->next) { waypoint *wpt_tmp; - switch (pdb->version) + switch (file_in->version) { case 0: wpt_tmp = read_version0(pdb_rec->data); @@ -247,19 +240,16 @@ data_read(void) wpt_tmp = read_version4(pdb_rec->data); break; default: - fatal(MYNAME ": Unknown version %d.\n", pdb->version); + fatal(MYNAME ": Unknown version %d.\n", file_in->version); } waypt_add(wpt_tmp); - } - free_pdb(pdb); } static void copilot_writewpt(const waypoint *wpt) { struct record4 *rec; - static int ct = 0; char *vdata; rec = xcalloc(sizeof(*rec)+1141,1); @@ -297,36 +287,23 @@ copilot_writewpt(const waypoint *wpt) } vdata += strlen( vdata ) + 1; - opdb_rec = new_Record (0, 2, ct++, (uword) (vdata-(char *)rec), (const ubyte *)rec); - - if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record\n"); - } + pdb_write_rec(file_out, 0, 2, ct++, rec, (char *)vdata - (char *)rec); - if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record\n"); - } xfree(rec); } static void data_write(void) { - if (NULL == (opdb = new_pdb())) { - fatal (MYNAME ": new_pdb failed\n"); - } - - strncpy(opdb->name, out_fname, PDB_DBNAMELEN); - opdb->name[PDB_DBNAMELEN-1] = 0; - opdb->attributes = PDB_ATTR_BACKUP; - opdb->ctime = opdb->mtime = current_time() + 2082844800U; - opdb->type = wayp_TYPE; - opdb->creator = GXPU_CREATOR; - opdb->version = 4; + strncpy(file_out->name, out_fname, PDB_DBNAMELEN); + file_out->name[PDB_DBNAMELEN-1] = 0; + file_out->attr = PDB_FLAG_BACKUP; + file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->type = wayp_TYPE; + file_out->creator = GXPU_CREATOR; + file_out->version = 4; waypt_disp_all(copilot_writewpt); - - pdb_Write(opdb, fileno(file_out)); } diff --git a/coto.c b/coto.c index c5dfc59f4..eff0692e7 100644 --- a/coto.c +++ b/coto.c @@ -26,8 +26,7 @@ #include "defs.h" #if PDBFMTS_ENABLED #include "csv_util.h" -#include "coldsync/palm.h" -#include "coldsync/pdb.h" +#include "pdbfile.h" #include "grtcirc.h" #define MYNAME "cotoGPS" @@ -58,14 +57,14 @@ struct record_track { pdb_double arc; /* Course, unknown dimension */ pdb_double x,y; /* Internal virtual coordinates used for drawing the track on the Palm */ - word alt; /* Altitude */ + gbuint16 alt; /* Altitude */ /* accuracy and precision information for use where applicable */ gbuint16 hdop; /* _dop * 10 */ gbuint16 vdop; gbuint16 pdop; - ubyte sat_tracked; - ubyte fix_quality; + gbuint8 sat_tracked; + gbuint8 fix_quality; gbuint16 speed; /* *10 */ gbuint32 time; /* Palm Time */ @@ -84,21 +83,20 @@ struct record_wpt { typedef char appinfo_category[16]; typedef struct appinfo { - ubyte U0; - ubyte renamedCategories; + gbuint8 U0; + gbuint8 renamedCategories; appinfo_category categories[CATEGORY_NAME_LENGTH]; - ubyte ids[16]; - ubyte maxid; + gbuint8 ids[16]; + gbuint8 maxid; } appinfo_t; #define APPINFO_SIZE sizeof(appinfo_t) -static FILE *file_in; -static FILE *file_out; +static pdbfile *file_in, *file_out; static const char *out_fname; static const char *in_fname; /* We might need that for naming tracks */ -static struct pdb *opdb; static short_handle mkshort_wr_handle; +static int ct; static char *zerocat = NULL; static char *internals = NULL; @@ -115,27 +113,28 @@ arglist_t coto_args[] = { static void rd_init(const char *fname) { - file_in = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); in_fname = fname; } static void rd_deinit(void) { - fclose(file_in); + pdb_close(file_in); } static void wr_init(const char *fname) { - file_out = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); out_fname = fname; + ct = 0; } static void wr_deinit(void) { - fclose(file_out); + pdb_close(file_out); } /* helpers */ @@ -157,16 +156,16 @@ coto_get_icon_descr(int category, const appinfo_t *app) } static void -coto_track_read(struct pdb *pdb) +coto_track_read(void) { struct record_track *rec; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; route_head *trk_head; char *track_name; - if (strncmp(pdb->name, "cotoGPS TrackDB", PDB_DBNAMELEN) != 0) + if (strncmp(file_in->name, "cotoGPS TrackDB", PDB_DBNAMELEN) != 0) // Use database name if not default - track_name = xstrndup(pdb->name, PDB_DBNAMELEN); + track_name = xstrndup(file_in->name, PDB_DBNAMELEN); else { // Use filename for new track title const char *fnametmp = strrchr(in_fname, '/'); @@ -187,7 +186,7 @@ coto_track_read(struct pdb *pdb) trk_head->rte_name = track_name; - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) + for (pdb_rec = file_in->rec_list; pdb_rec; pdb_rec = pdb_rec->next) { waypoint *wpt_tmp; @@ -199,7 +198,7 @@ coto_track_read(struct pdb *pdb) wpt_tmp->latitude = DEG(pdb_read_double(&rec->latitude)); // It's not the course, so leave it out for now - // wpt_tmp->course = pdb_read_double(&rec->arc); + // WAYPT_SET(wpt_tmp, course, pdb_read_double(&rec->arc)); wpt_tmp->altitude = be_read16(&rec->alt); if (internals) @@ -234,7 +233,7 @@ coto_track_read(struct pdb *pdb) wpt_tmp->fix = fix_dgps; break; } - wpt_tmp->speed = be_read16(&rec->speed)/10.0; + WAYPT_SET(wpt_tmp, speed, be_read16(&rec->speed)/10.0); rec->time = be_read32(&rec->time); if (rec->time != 0) { @@ -246,14 +245,14 @@ coto_track_read(struct pdb *pdb) } static void -coto_wpt_read(struct pdb *pdb) +coto_wpt_read(void) { struct record_wpt *rec; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; appinfo_t *app; - app = (struct appinfo *) pdb->appinfo; + app = (struct appinfo *) file_in->appinfo; - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) + for(pdb_rec = file_in->rec_list; pdb_rec; pdb_rec = pdb_rec->next) { waypoint *wpt_tmp; char *c; @@ -287,49 +286,42 @@ coto_wpt_read(struct pdb *pdb) static void data_read(void) { - struct pdb *pdb; - - if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed\n"); - } - - if ((pdb->creator != MYCREATOR) || ((pdb->type != MYTYPETRACK) && (pdb->type != MYTYPEWPT))) { - warning("Creator %x Type %x Version %d\n", (int) pdb->creator, (int) pdb->type, (int) pdb->version); + if ((file_in->creator != MYCREATOR) || ((file_in->type != MYTYPETRACK) && (file_in->type != MYTYPEWPT))) { + warning("Creator %x Type %x Version %d\n", (int) file_in->creator, (int) file_in->type, (int) file_in->version); fatal(MYNAME ": Not a cotoGPS file.\n"); } - is_fatal((pdb->version > 0), + is_fatal((file_in->version > 0), MYNAME ": This file is from an unsupported newer version of cotoGPS. It may be supported in a newer version of GPSBabel.\n"); - switch(pdb->type) + switch(file_in->type) { case MYTYPETRACK: - coto_track_read(pdb); + coto_track_read(); break; case MYTYPEWPT: - coto_wpt_read(pdb); + coto_wpt_read(); break; } - - free_pdb(pdb); } static void -coto_prepare_wpt_write(struct pdb *opdb) +coto_prepare_wpt_write(void) { struct appinfo *ai; - opdb->name[PDB_DBNAMELEN-1] = 0; - opdb->attributes = PDB_ATTR_BACKUP; - opdb->type = MYTYPEWPT; - opdb->creator = MYCREATOR; - opdb->version = 0; + + file_out->name[PDB_DBNAMELEN-1] = 0; + file_out->attr = PDB_FLAG_BACKUP; + file_out->type = MYTYPEWPT; + file_out->creator = MYCREATOR; + file_out->version = 0; - strncpy(opdb->name, "cotoGPS MarkerDB", PDB_DBNAMELEN); + strncpy(file_out->name, "cotoGPS MarkerDB", PDB_DBNAMELEN); - opdb->appinfo_len = APPINFO_SIZE; - opdb->appinfo = calloc(APPINFO_SIZE,1); + file_out->appinfo_len = APPINFO_SIZE; + file_out->appinfo = calloc(APPINFO_SIZE,1); - ai = (struct appinfo *) opdb->appinfo; + ai = (struct appinfo *) file_out->appinfo; be_write16(&ai->renamedCategories, 31); // Don't ask me why... if (zerocat) strncpy(ai->categories[0], zerocat, 16); @@ -342,13 +334,11 @@ static void coto_wpt_write(const waypoint *wpt) { struct record_wpt *rec; - struct appinfo *ai = (struct appinfo *) opdb->appinfo; - static int ct; - struct pdb_record *opdb_rec; + struct appinfo *ai = (struct appinfo *) file_out->appinfo; char *notes = NULL; char *shortname = NULL; int size; - ubyte cat = 0; + gbuint8 cat = 0; int i; mkshort_wr_handle = mkshort_new_handle(); @@ -407,14 +397,8 @@ coto_wpt_write(const waypoint *wpt) } } - opdb_rec = new_Record (0, cat, ct++, size, (const ubyte *)rec); + pdb_write_rec(file_out, 0, cat, ct++, (const gbuint8 *)rec, size); - if (opdb_rec == NULL) - fatal(MYNAME ": libpdb couldn't create record\n"); - - if (pdb_AppendRecord(opdb, opdb_rec)) - fatal(MYNAME ": libpdb couldn't append record\n"); - xfree(shortname); xfree(rec); @@ -424,22 +408,8 @@ coto_wpt_write(const waypoint *wpt) static void data_write(void) { - if (NULL == (opdb = new_pdb())) { - fatal (MYNAME ": new_pdb failed\n"); - } - - coto_prepare_wpt_write(opdb); - + coto_prepare_wpt_write(); waypt_disp_all(coto_wpt_write); - /* - if we want waypoints from all data, we should create a new filter for that - - track_disp_all(NULL, NULL, coto_wpt_write); - route_disp_all(NULL, NULL, coto_wpt_write); - */ - - pdb_Write(opdb, fileno(file_out)); - } diff --git a/csv_util.c b/csv_util.c index 3fe89dd1c..81b833b76 100644 --- a/csv_util.c +++ b/csv_util.c @@ -21,11 +21,13 @@ */ #include +#include #include "defs.h" #include "csv_util.h" #include "grtcirc.h" #include "strptime.h" #include "jeeps/gpsmath.h" +#include "xmlgeneric.h" // for xml_fill_in_time. #define MYNAME "CSV_UTIL" @@ -57,6 +59,7 @@ static double oldlon = 999; static double oldlat = 999; static int waypt_out_count; +static route_head *csv_track, *csv_route; /*********************************************************************/ /* csv_stringclean() - remove any unwanted characters from string. */ @@ -682,6 +685,11 @@ sscanftime( const char *s, const char *format, const int gmt ) if ( strptime( s, format, &stm ) ) { + if ((stm.tm_mday == 0) && (stm.tm_mon == 0) && (stm.tm_year == 0)) { + stm.tm_mday = 1; + stm.tm_mon = 0; + stm.tm_year = 70; + } stm.tm_isdst = -1; if (gmt) return mkgmtime(&stm); @@ -843,6 +851,9 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) if ( strcmp(fmp->key, "LAT_NMEA") == 0) { wpt->latitude = ddmm2degrees(atof(s)); } else + if ( strncmp(fmp->key, "LAT_10E", 7) == 0) { + wpt->latitude = atof(s) / pow((double)10, atof(fmp->key+7)); + } else /* LONGITUDE CONVERSIONS ***********************************************/ if (strcmp(fmp->key, "LON_DECIMAL") == 0) { /* longitude as a pure decimal value */ @@ -863,6 +874,9 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) if ( strcmp(fmp->key, "LON_NMEA") == 0) { wpt->longitude = ddmm2degrees(atof(s)); } else + if ( strncmp(fmp->key, "LON_10E", 7) == 0) { + wpt->longitude = atof(s) / pow((double)10, atof(fmp->key+7)); + } else /* LAT AND LON CONVERSIONS ********************************************/ if ( strcmp(fmp->key, "LATLON_HUMAN_READABLE") == 0) { human_to_dec( s, &wpt->latitude, &wpt->longitude, 0 ); @@ -874,23 +888,40 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) if (strcmp(fmp->key, "LON_DIR") == 0) { /* longitude E/W. Ingore on input for now */ } else - + /* SPECIAL COORDINATES/GRID */ + if (strcmp(fmp->key, "MAP_EN_BNG") == 0) { + parse_coordinates(s, DATUM_OSGB36, grid_bng, + &wpt->latitude, &wpt->longitude, MYNAME); + } else /* ALTITUDE CONVERSIONS ************************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { /* altitude in feet as a decimal value */ wpt->altitude = FEET_TO_METERS(atof(s)); + if (wpt->altitude < unknown_alt + 1) + wpt->altitude = unknown_alt; } else if (strcmp(fmp->key, "ALT_METERS") == 0) { /* altitude in meters as a decimal value */ wpt->altitude = atof(s); + if (wpt->altitude < unknown_alt + 1) + wpt->altitude = unknown_alt; } else /* PATH CONVERSIONS ************************************************/ if (strcmp(fmp->key, "PATH_SPEED") == 0) { - wpt->speed = atof(s); + WAYPT_SET(wpt, speed, atof(s)); + } else + if (strcmp(fmp->key, "PATH_SPEED_KPH") == 0) { + WAYPT_SET(wpt, speed, KPH_TO_MPS(atof(s))); + } else + if (strcmp(fmp->key, "PATH_SPEED_MPH") == 0) { + WAYPT_SET(wpt, speed, MPH_TO_MPS(atof(s))); + } else + if (strcmp(fmp->key, "PATH_SPEED_KNOTS") == 0) { + WAYPT_SET(wpt, speed, KNOTS_TO_MPS(atof(s))); } else if (strcmp(fmp->key, "PATH_COURSE") == 0) { - wpt->course = atof(s); + WAYPT_SET(wpt, course, atof(s)); } else /* TIME CONVERSIONS ***************************************************/ @@ -917,8 +948,9 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) (strcmp(fmp->key, "HMSL_TIME") == 0) ) { wpt->creation_time += addhms(s, fmp->printfc); } else - if (strcmp(fmp->key, "ISO_TIME") == 0) { - wpt->creation_time = xml_parse_time(s, NULL); + if ((strcmp(fmp->key, "ISO_TIME") == 0) || + (strcmp(fmp->key, "ISO_TIME_MS") == 0)) { + wpt->creation_time = xml_parse_time(s, &wpt->microseconds); } else if (strcmp(fmp->key, "GEOCACHE_LAST_FOUND") == 0) { wpt->gc_data.last_found = yyyymmdd_to_time(s); @@ -973,6 +1005,13 @@ xcsv_parse_val(const char *s, waypoint *wpt, const field_map_t *fmp) wpt->fix = fix_unknown; } } else + /* Tracks and routes *********************************************/ + if ( strcmp ( fmp->key, "ROUTE_NAME") == 0) { + if (csv_route) csv_route->rte_name = csv_stringtrim(s, enclosure, 0); + } else + if ( strcmp ( fmp->key, "TRACK_NAME") == 0) { + if (csv_track) csv_track->rte_name = csv_stringtrim(s, enclosure, 0); + } else /* OTHER STUFF ***************************************************/ if ( strcmp( fmp->key, "PATH_DISTANCE_MILES") == 0) { @@ -1008,13 +1047,16 @@ xcsv_data_read(void) route_head *rte = NULL; route_head *trk = NULL; + csv_route = csv_track = NULL; if (xcsv_file.datatype == trkdata) { trk = route_head_alloc(); track_add_head(trk); + csv_track = trk; } else if (xcsv_file.datatype == rtedata) { rte = route_head_alloc(); route_add_head(rte); + csv_route = rte; } while ((buff = gbfgetstr(xcsv_file.xcsvfp))) { @@ -1049,6 +1091,10 @@ xcsv_data_read(void) s = buff; s = csv_lineparse(s, xcsv_file.field_delimiter, "", linecount); + if (QUEUE_EMPTY(&xcsv_file.ifield)) { + fatal(MYNAME ": attempt to read, but style '%s' has no IFIELDs in it.\n", xcsv_file.description? xcsv_file.description : "unknown"); + } + /* reset the ifield queue */ elem = QUEUE_FIRST(&xcsv_file.ifield); @@ -1098,6 +1144,17 @@ xcsv_resetpathlen(const route_head *head) pathdist = 0; oldlat = 999; oldlon = 999; + csv_route = csv_track = NULL; + switch (xcsv_file.datatype) { + case trkdata: + csv_track = (route_head *) head; + break; + case rtedata: + csv_route = (route_head *) head; + break; + default: + break; + } } /*****************************************************************************/ @@ -1116,6 +1173,8 @@ xcsv_waypt_pr(const waypoint *wpt) field_map_t *fmp; queue *elem, *tmp; double latitude, longitude; + + buff[0] = '\0'; if ( oldlon < 900 ) { pathdist += radtomiles(gcdist(RAD(oldlat),RAD(oldlon), @@ -1288,6 +1347,9 @@ xcsv_waypt_pr(const waypoint *wpt) if (strcmp(fmp->key, "LAT_NMEA") == 0) { writebuff(buff, fmp->printfc, degrees2ddmm(lat)); } else + if (strncmp(fmp->key, "LAT_10E", 7) == 0) { + writebuff(buff, fmp->printfc, lat * pow((double)10, atof(fmp->key+7))); + } else /* LONGITUDE CONVERSIONS*********************************************/ if (strcmp(fmp->key, "LON_DECIMAL") == 0) { @@ -1323,6 +1385,9 @@ xcsv_waypt_pr(const waypoint *wpt) if (strcmp(fmp->key, "LON_NMEA") == 0) { writebuff(buff, fmp->printfc, degrees2ddmm(lon)); } else + if (strncmp(fmp->key, "LON_10E", 7) == 0) { + writebuff(buff, fmp->printfc, lon * pow((double)10, atof(fmp->key+7))); + } else /* DIRECTIONS *******************************************************/ if (strcmp(fmp->key, "LAT_DIR") == 0) { @@ -1335,6 +1400,16 @@ xcsv_waypt_pr(const waypoint *wpt) writebuff(buff, fmp->printfc, LON_DIR(lon)); } else + + /* SPECIAL COORDINATES */ + if (strcmp(fmp->key, "MAP_EN_BNG") == 0) { + char map[3]; + double north, east; + if (! GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map)) + fatal(MYNAME ": Position (%.5f/%.5f) outside of BNG.\n", + wpt->latitude, wpt->longitude); + snprintf(buff, sizeof(buff), fmp->printfc, map, (int)(east + 0.5), (int)(north + 0.5)); + } else /* ALTITUDE CONVERSIONS**********************************************/ if (strcmp(fmp->key, "ALT_FEET") == 0) { @@ -1360,6 +1435,15 @@ xcsv_waypt_pr(const waypoint *wpt) if (strcmp(fmp->key, "PATH_SPEED") == 0) { writebuff( buff, fmp->printfc, wpt->speed ); } else + if (strcmp(fmp->key, "PATH_SPEED_KPH") == 0) { + writebuff( buff, fmp->printfc, MPS_TO_KPH(wpt->speed)); + } else + if (strcmp(fmp->key, "PATH_SPEED_MPH") == 0) { + writebuff( buff, fmp->printfc, MPS_TO_MPH(wpt->speed)); + } else + if (strcmp(fmp->key, "PATH_SPEED_KNOTS") == 0) { + writebuff( buff, fmp->printfc, MPS_TO_KNOTS(wpt->speed)); + } else if (strcmp(fmp->key, "PATH_COURSE") == 0) { writebuff( buff, fmp->printfc, wpt->course ); } else @@ -1399,6 +1483,10 @@ xcsv_waypt_pr(const waypoint *wpt) if (strcmp(fmp->key, "ISO_TIME") == 0) { writetime(buff, sizeof buff, "%Y-%m-%dT%H:%M:%SZ", wpt->creation_time, 1 ); } else + if (strcmp(fmp->key, "ISO_TIME_MS") == 0) { + xml_fill_in_time(buff, wpt->creation_time, + wpt->microseconds, XML_LONG_TIME); + } else if (strcmp(fmp->key, "GEOCACHE_LAST_FOUND") == 0) { writebuff(buff, fmp->printfc, time_to_yyyymmdd(wpt->gc_data.last_found)); } else @@ -1432,6 +1520,13 @@ xcsv_waypt_pr(const waypoint *wpt) writebuff(buff, fmp->printfc, NONULL(wpt->gc_data.placer)); field_is_unknown = !wpt->gc_data.placer; } else + /* Tracks and Routes ***********************************************/ + if (strcmp(fmp->key, "TRACK_NAME") == 0) { + if (csv_track) writebuff(buff, fmp->printfc, NONULL(csv_track->rte_name)); + } else + if (strcmp(fmp->key, "ROUTE_NAME") == 0) { + if (csv_route) writebuff(buff, fmp->printfc, NONULL(csv_route->rte_name)); + } else /* GPS STUFF *******************************************************/ if (strcmp(fmp->key, "GPS_HDOP") == 0) { @@ -1474,10 +1569,8 @@ xcsv_waypt_pr(const waypoint *wpt) break; } writebuff(buff, fmp->printfc, fix); - } else - - { - /* this should probably never happen */ + } else { + warning( MYNAME ": Unknown style directive: %s\n", fmp->key); } @@ -1528,29 +1621,65 @@ xcsv_data_write(void) { queue *elem, *tmp; ogue_t *ogp; + time_t time; + struct tm tm; + char tbuf[32]; /* reset the index counter */ waypt_out_count = 0; + + time = gpsbabel_time; + if (time == 0) /* testo script ? */ + tm = *gmtime(&time); + else + tm = *localtime(&time); /* output prologue lines, if any. */ QUEUE_FOR_EACH(&xcsv_file.prologue, elem, tmp) { - char *ol; + char *cout, *ctmp; ogp = (ogue_t *) elem; - ol = strsub(ogp->val, "__FILE__", xcsv_file.fname); + cout = xstrdup((ogp->val) ? ogp->val : ""); + + while ((ctmp = strsub(cout, "__FILE__", xcsv_file.fname))) { + xfree(cout); + cout = ctmp; + } + + while ((ctmp = strsub(cout, "__VERSION__", (time == 0) ? "" : gpsbabel_version))) { + xfree(cout); + cout = ctmp; + } + + while (strstr(cout, "__DATE__")) { + strftime(tbuf, sizeof(tbuf), "%m/%d/%Y", &tm); + ctmp = strsub(cout, "__DATE__", tbuf); + xfree(cout); + cout = ctmp; + } - if (ol) { - gbfprintf(xcsv_file.xcsvfp, "%s", ol); - xfree(ol); - } else { - gbfprintf(xcsv_file.xcsvfp, "%s", ogp->val); + while (strstr(cout, "__TIME__")) { + strftime(tbuf, sizeof(tbuf), "%H:%S:%M", &tm); + ctmp = strsub(cout, "__TIME__", tbuf); + xfree(cout); + cout = ctmp; } + + while (strstr(cout, "__DATE_AND_TIME__")) { + strftime(tbuf, sizeof(tbuf), "%a %b %d %H:%M:%S %Y", &tm); + ctmp = strsub(cout, "__DATE_AND_TIME__", tbuf); + xfree(cout); + cout = ctmp; + } + + gbfprintf(xcsv_file.xcsvfp, "%s", cout); + xfree(cout); gbfprintf(xcsv_file.xcsvfp, "%s", xcsv_file.record_delimiter); } if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == wptdata)) waypt_disp_all(xcsv_waypt_pr); - if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == rtedata)) + if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == rtedata)) route_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr); if ((xcsv_file.datatype == 0) || (xcsv_file.datatype == trkdata)) track_disp_all(xcsv_resetpathlen,xcsv_noop,xcsv_waypt_pr); diff --git a/defs.h b/defs.h index 0c8e081a5..eb109dd21 100644 --- a/defs.h +++ b/defs.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002, 2003, 2004, 2005 Robert Lipe, robertlipe@usa.net + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Robert Lipe, robertlipe@usa.net This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -64,6 +64,24 @@ #define SECONDS_PER_HOUR (60L*60) #define SECONDS_PER_DAY (24L*60*60) +/* meters/second to kilometers/hour */ +#define MPS_TO_KPH(a) ((double)(a)*SECONDS_PER_HOUR/1000) + +/* meters/second to miles/hour */ +#define MPS_TO_MPH(a) (METERS_TO_MILES(a) * SECONDS_PER_HOUR) + +/* meters/second to knots */ +#define MPS_TO_KNOTS(a) (MPS_TO_KPH((a)/1.852)) + +/* kilometers/hour to meters/second */ +#define KPH_TO_MPS(a) ((double)(a)*1000/SECONDS_PER_HOUR) + +/* miles/hour to meters/second */ +#define MPH_TO_MPS(a) (MILES_TO_METERS(a) / SECONDS_PER_HOUR) + +/* knots to meters/second */ +#define KNOTS_TO_MPS(a) (KPH_TO_MPS((a)*1.852)) + /* * Snprintf is in SUS (so it's in most UNIX-like substance) and it's in * C99 (albeit with slightly different semantics) but it isn't in C89. @@ -218,6 +236,7 @@ typedef struct { time_t exported; time_t last_found; char *placer; /* Placer name */ + int placer_id; /* Placer id */ char *hint; /* all these UTF8, XML entities removed, May be not HTML. */ utf_string desc_short; utf_string desc_long; @@ -267,6 +286,15 @@ fs_xml *fs_xml_alloc( long type ); #define FS_OZI 0x6f7a6900L #define FS_GMSD 0x474d5344L /* GMSD = Garmin specific data */ +/* + * Structures and functions for multiple URLs per waypoint. + */ +typedef struct url_link { + struct url_link *url_next; + char *url; + char *url_link_text; +} url_link; + /* * Misc bitfields inside struct waypoint; */ @@ -274,8 +302,23 @@ typedef struct { unsigned int icon_descr_is_dynamic:1; unsigned int shortname_is_synthetic:1; unsigned int cet_converted:1; /* strings are converted to UTF8; interesting only for input */ + /* "flagged fields" */ + unsigned int temperature:1; /* temperature field is set */ + unsigned int proximity:1; /* proximity field is set */ + unsigned int course:1; /* course field is set */ + unsigned int speed:1; /* speed field is set */ + unsigned int depth:1; /* depth field is set */ + /* !ToDo! + unsigned int altitude:1; /+ altitude field is set +/ + ... and others + */ + } wp_flags; +#define WAYPT_SET(wpt,member,val) { wpt->member = (val); wpt->wpt_flags.member = 1; } +#define WAYPT_GET(wpt,member,def) (wpt->wpt_flags.member) ? (wpt->member) : (def) +#define WAYPT_UNSET(wpt,member) wpt->wpt_flags.member = 0 +#define WAYPT_HAS(wpt,member) (wpt->wpt_flags.member) /* * This is a waypoint, as stored in the GPSR. It tries to not * cater to any specific model or protocol. Anything that needs to @@ -325,6 +368,15 @@ typedef struct { * Few formats support this. */ char *notes; + + /* This is a bit icky. Multiple waypoint support is an + * afterthought and I don't want to change our data structures. + * So we have the first in the waypoint itself and subsequent + * ones in a linked list. + * We also use an implicit anonymous union here, so these three + * members must match struct url_link... + */ + struct url_link *url_next; char *url; char *url_link_text; @@ -400,14 +452,18 @@ typedef struct { typedef struct { double max_lat; double max_lon; + double max_alt; double min_lat; double min_lon; + double min_alt; } bounds; typedef struct { - int request_terminate; + volatile int request_terminate; } posn_status; +extern posn_status tracking_status; + typedef void (*ff_init) (char const *); typedef void (*ff_deinit) (void); typedef void (*ff_read) (void); @@ -446,6 +502,7 @@ void waypt_flush(queue *); void waypt_flush_all(void); unsigned int waypt_count(void); void set_waypt_count(unsigned int nc); +void waypt_add_url(waypoint *wpt, char *link, char *url_link_text); void free_gpx_extras (xml_tag * tag); void xcsv_setup_internal_style(const char *style_buf); void xcsv_read_internal_style(const char *style_buf); @@ -639,6 +696,8 @@ void waypt_init(void); void route_init(void); void waypt_disp(const waypoint *); void waypt_status_disp(int total_ct, int myct); +double waypt_time(const waypoint *wpt); +double waypt_speed(const waypoint *A, const waypoint *B); NORETURN fatal(const char *, ...) PRINTFLIKE(1, 2); void is_fatal(const int condition, const char *, ...) PRINTFLIKE(2, 3); @@ -706,6 +765,7 @@ int case_ignore_strcmp(const char *s1, const char *s2); int case_ignore_strncmp(const char *s1, const char *s2, int n); int str_match(const char *str, const char *match); int case_ignore_str_match(const char *str, const char *match); +char * strenquote(const char *str, const char quot_char); char *strsub(const char *s, const char *search, const char *replace); char *gstrsub(const char *s, const char *search, const char *replace); @@ -729,7 +789,7 @@ char * strip_html(const utf_string*); char * strip_nastyhtml(const char * in); char * convert_human_date_format(const char *human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */ char * convert_human_time_format(const char *human_timef); /* "HH+mm+ss" -> "%H+%M+%S" */ -char * pretty_deg_format(double lat, double lon, char fmt, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ +char * pretty_deg_format(double lat, double lon, char fmt, char *sep, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ char * get_filename(const char *fname); /* extract the filename portion */ @@ -825,6 +885,24 @@ void le_write_double(void *p, double d); double ddmm2degrees(double ddmm_val); double degrees2ddmm(double deg_val); +typedef enum { + grid_unknown = -1, + grid_lat_lon_ddd = 0, + grid_lat_lon_dmm = 1, + grid_lat_lon_dms = 2, + grid_bng = 3, + grid_utm = 4 +} grid_type; + +#define GRID_INDEX_MIN grid_lat_lon_ddd +#define GRID_INDEX_MAX grid_utm + +#define DATUM_OSGB36 86 +#define DATUM_WGS84 118 + +int parse_coordinates(const char *str, int datum, const grid_type grid, + double *latitude, double *longitude, const char *module); + /* * From util_crc.c */ @@ -864,28 +942,5 @@ int color_to_bbggrr(char *cname); * but that's not very nice for the folks near sea level. */ #define unknown_alt -99999999.0 -#define unknown_course -999.0 -#define unknown_speed -999.0 -/* - * textfile: buffered OS independent (CRLF,NL,CR) text reader - */ - -typedef struct -{ - FILE *file_in; - char buf[1024]; - char *buf_pos; - char *buf_end; - char *line; - int line_size; - int line_no; - unsigned char tfclose:1; -} textfile_t; - -textfile_t *textfile_init(const FILE *file_in); -textfile_t *textfile_open_read(const char *filename, const char *module); -void textfile_done(textfile_t *tf); -char *textfile_read(textfile_t *tf); -int textfile_getc(textfile_t *tf); #endif /* gpsbabel_defs_h_included */ diff --git a/delgpl.c b/delgpl.c index 76c88180c..6f6e1fc2b 100644 --- a/delgpl.c +++ b/delgpl.c @@ -68,11 +68,13 @@ gpl_read(void) wpt_tmp->longitude = le_read_double(&gp.lon); alt_feet = le_read_double(&gp.alt); wpt_tmp->altitude = FEET_TO_METERS(alt_feet); + if (wpt_tmp->altitude <= unknown_alt + 1) + wpt_tmp->altitude = unknown_alt; wpt_tmp->creation_time = le_read32(&gp.tm); - wpt_tmp->course = le_read_double(&gp.heading); - wpt_tmp->speed = le_read_double(&gp.speed); - wpt_tmp->speed = MILES_TO_METERS(wpt_tmp->speed)/3600; + WAYPT_SET(wpt_tmp, course, le_read_double(&gp.heading)); + WAYPT_SET(wpt_tmp, speed, le_read_double(&gp.speed)); + WAYPT_SET(wpt_tmp, speed, MILES_TO_METERS(wpt_tmp->speed)/3600); track_add_wpt(track_head, wpt_tmp); } diff --git a/dmtlog.c b/dmtlog.c index 785ab0050..9a88c50aa 100644 --- a/dmtlog.c +++ b/dmtlog.c @@ -38,7 +38,7 @@ static char *xmlbin; static waypoint *xmlwpt; static route_head *xmltrk; static char *xmlgrid; -static int xmldatum, datum_WGS84, datum_OSGB36; +static int xmldatum; static double xmlEasting, xmlNorthing; static double xmlLatitude, xmlLongitude; static double xmlAltitude; @@ -105,7 +105,7 @@ static xg_tag_mapping tlog3b_xgcb_map[] = { static void convert_datum(waypoint *wpt, int datum) { - if (datum != datum_WGS84) { + if (datum != DATUM_WGS84) { double lat = wpt->latitude; double lon = wpt->longitude; double alt = wpt->altitude; @@ -122,7 +122,7 @@ finalize_pt(waypoint *wpt) if (strcmp(xmlgrid, "BNG") == 0) { GPS_Math_NGENToAiry1830LatLon(xmlEasting, xmlNorthing, &wpt->latitude, &wpt->longitude); - xmldatum = datum_OSGB36; + xmldatum = DATUM_OSGB36; } else { wpt->latitude = xmlLatitude; @@ -219,7 +219,7 @@ static void tlog3b_xgcb_wptst(const char *args, const char **unused) { xmlwpt = waypt_new(); - xmldatum = datum_WGS84; + xmldatum = DATUM_WGS84; } @@ -227,7 +227,7 @@ static void tlog3b_xgcb_tptst(const char *args, const char **unused) { xmlwpt = waypt_new(); - xmldatum = datum_WGS84; + xmldatum = DATUM_WGS84; } @@ -551,9 +551,6 @@ dmtlog_rd_init(const char *fname) { fin = gbfopen_le(fname, "rb", MYNAME); - datum_OSGB36 = GPS_Lookup_Datum_Index("OSGB36"); - datum_WGS84 = GPS_Lookup_Datum_Index("WGS84"); - xmlbin = NULL; xmltrk = NULL; xmlwpt = NULL; diff --git a/g7towin.c b/g7towin.c new file mode 100644 index 000000000..2aca83e66 --- /dev/null +++ b/g7towin.c @@ -0,0 +1,546 @@ +/* + + Support for G7ToWin data files (.g7t), + Copyright (C) 2007 Olaf Klein, o.b.klein@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA +*/ + +/* + History: + 04/07/2007: start programming + 04/15/2007: added to gpsbabel +*/ + +#include "defs.h" +#include "csv_util.h" +#include "garmin_fs.h" +#include "garmin_tables.h" +#include "jeeps/gpsmath.h" +#include "strptime.h" + +#include + +#if CSVFMTS_ENABLED + +#define MYNAME "g7towin" + +#define G7T_HEADER "Version 2:G7T" + +static gbfile *fin; +static grid_type grid; +static int datum; +static gpsdata_type mode; +static double altf; +static int gardown; +static int event_ct; + +static +arglist_t g7towin_args[] = { + ARG_TERMINATOR +}; + +#define WAYPT__OFS 0x00000 +#define TRKPT__OFS 0x01000 + +#define WPT_c0_OFS 0x0c000 +#define WPT_c1_OFS 0x0c100 +#define WPT_c2_OFS 0x0c200 +#define WPT_c3_OFS 0x0c300 +#define WPT_c4_OFS 0x0c400 +#define WPT_c5_OFS 0x0c500 +#define WPT_c6_OFS 0x0c600 +#define WPT_c7_OFS 0x0c700 +#define WPT_c8_OFS 0x0c800 +#define WPT_cA_OFS 0x0cA00 +#define WPT_cB_OFS 0x0cB00 +#define WPT_cC_OFS 0x0cC00 +#define WPT_cD_OFS 0x0cD00 + +static void +parse_line(char *buff, int index, const char *delimiter, waypoint *wpt) +{ + char *cin; + garmin_fs_p gmsd = GMSD_FIND(wpt); + + while ((cin = csv_lineparse(buff, delimiter, "", index++))) { + + buff = NULL; + cin = lrtrim(cin); + + if ((*cin == '\0') || + (strcmp(cin, "INF") == 0) || + (strcmp(cin, "1e25") == 0) || + (strcmp(cin, "1.0e25") == 0)) continue; + + switch(index) { + + int categories, dyn; + struct tm tm; + char *cerr; + + case TRKPT__OFS + 1: + cin += parse_coordinates(cin, datum, grid, + &wpt->latitude, &wpt->longitude, MYNAME); + while (isspace(*cin)) cin++; + + memset(&tm, 0, sizeof(tm)); + cerr = strptime(cin, "%a %b %d %H:%M:%S %Y", &tm); + if (cerr == NULL) { + fatal(MYNAME ": Unable to convert date (%s)!\n", cin); + } + wpt->creation_time = mkgmtime(&tm); + break; + + case WAYPT__OFS + 1: + wpt->description = xstrdup(cin); + break; + + case WAYPT__OFS + 2: + wpt->icon_descr = gt_find_desc_from_icon_number( + atoi(cin), PCX, &dyn); + wpt->wpt_flags.icon_descr_is_dynamic = dyn; + break; + + case WAYPT__OFS + 4: + if (strcmp(cin, "S+C") == 0) { + GMSD_SET(display, gt_display_mode_symbol_and_comment); + } + else if (strcmp(cin, "S") == 0) { + GMSD_SET(display, gt_display_mode_symbol); + } + else if (strcmp(cin, "S+N") == 0) { + GMSD_SET(display, gt_display_mode_symbol_and_name); + } + break; + + case WPT_cA_OFS + 1: + case WPT_c1_OFS + 1: + if (wpt->shortname) xfree(wpt->shortname); + wpt->shortname = xstrdup(cin); + break; + + case WPT_cA_OFS + 4: + case WPT_c4_OFS + 2: + GMSD_SETSTR(city, cin); + break; + + case WPT_cA_OFS + 5: + case WPT_c4_OFS + 3: + GMSD_SETSTR(state, cin); + break; + + case WPT_cA_OFS + 6: + case WPT_c4_OFS + 4: + GMSD_SETSTR(cc, cin); + break; + + case WPT_cB_OFS + 1: + case WPT_c6_OFS + 2: + GMSD_SETSTR(facility, cin); + break; + + case WPT_cB_OFS + 2: + case WPT_c6_OFS + 3: + GMSD_SETSTR(addr, cin); + break; + + case WPT_cB_OFS + 3: /*cross road */ + case WPT_c6_OFS + 4: + GMSD_SETSTR(cross_road, cin); + break; + + case TRKPT__OFS + 2: /* altitude */ + case WPT_cC_OFS + 1: + case WPT_c5_OFS + 1: + case WPT_c8_OFS + 1: + wpt->altitude = altf * atof(cin); + break; + + case TRKPT__OFS + 3: /* depth */ + case WPT_cC_OFS + 2: + case WPT_c5_OFS + 2: + case WPT_c8_OFS + 2: + WAYPT_SET(wpt, depth, altf * atof(cin)); + break; + + case TRKPT__OFS + 10: /* temperature */ + if (*cin == '|') cin++; /* in track points */ + if (strcmp(cin, "1e25") == 0) break; + if (strcmp(cin, "1.0e25") == 0) break; + /* !!! NO BREAK !!! */ + case WPT_cD_OFS + 1: + case WPT_cB_OFS + 6: + WAYPT_SET(wpt, temperature, atof(cin)); + break; + + case WAYPT__OFS + 6: /* proximity */ + case WPT_cD_OFS + 2: + WAYPT_SET(wpt, proximity, atof(cin)); + break; + + case WPT_cB_OFS + 5: + case WPT_cD_OFS + 3: + categories = atoi(cin); + if (categories != 0) + GMSD_SET(category, atoi(cin)); + break; + +#if 0 + +/* currently unused */ + + case TRKPT__OFS + 5: /* distance from previous point */ + case TRKPT__OFS + 6: /* distance from segment start */ + case TRKPT__OFS + 7: /* distance from start */ + case TRKPT__OFS + 8: /* velocity from previous point */ + case TRKPT__OFS + 9: /* time (in seconds) from previous point */ + break; + + case WAYPT__OFS + 3: /* ignore color */ + break; + + case WAYPT__OFS + 5: /* always '0' */ + break; + + case TRKPT__OFS + 4: + if (case_ignore_strcmp(cin, "FT") == 0) ; + else if (case_ignore_strcmp(cin, "M") == 0) ; + else if (case_ignore_strcmp(cin, "SM") == 0) ; + else if (case_ignore_strcmp(cin, "NM") == 0) ; + else if (case_ignore_strcmp(cin, "KM") == 0) ; + break; + + case WPT_cB_OFS + 4: /* unknown (datatype) */ + break; + + case WPT_cC_OFS + 3: /* waypt_class (always FF) */ + break; + + case WPT_cC_OFS + 4: /* class & subclass */ + case WPT_cC_OFS + 5: + case WPT_cC_OFS + 6: + case WPT_cC_OFS + 7: + case WPT_cC_OFS + 8: + case WPT_cC_OFS + 9: + case WPT_cC_OFS + 10: + case WPT_cC_OFS + 11: + case WPT_cC_OFS + 12: + case WPT_cC_OFS + 13: + case WPT_cC_OFS + 14: + case WPT_cC_OFS + 15: + case WPT_cC_OFS + 16: + case WPT_cC_OFS + 17: + case WPT_cC_OFS + 18: + case WPT_cC_OFS + 19: + case WPT_cC_OFS + 20: + case WPT_cC_OFS + 21: + break; + + case WPT_cC_OFS + 22: + /* distance */ + break; +#endif + } + } +} + +static waypoint * +parse_waypt(char *buff) +{ + char *cin, *cerr; + int i; + struct tm tm; + waypoint *wpt; + garmin_fs_p gmsd; + + wpt = waypt_new(); + gmsd = garmin_fs_alloc(-1); + fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); + + if (gardown) + cin = buff + 6; + else { + /* We've seen waypoints with length of 14 and 15 !!! */ + cin = buff + 15; + while ((cin > buff) && (! isspace(*cin))) cin--; + } + + while (isspace(*cin)) cin--; + if (cin >= buff) + wpt->shortname = xstrndup(buff, cin - buff + 1); + + if (gardown) + buff += 6; + else + buff += 15; + while (isspace(*buff)) buff++; + + buff += parse_coordinates(buff, datum, grid, + &wpt->latitude, &wpt->longitude, MYNAME); + while (isspace(*buff)) buff++; + + memset(&tm, 0, sizeof(tm)); + cerr = strptime(buff, "%a %b %d %H:%M:%S %Y", &tm); + if (cerr == NULL) + fatal(MYNAME ": Unable to convert date (%s)!\n", buff); + wpt->creation_time = mkgmtime(&tm); + + /* go over time stamp */ + i = 5; + while (buff && i) { + i--; + buff = strchr(buff, ' '); + if (buff) buff++; + } + if (gardown && (buff == NULL)) return wpt; + is_fatal((buff == NULL), MYNAME ": Incomplete waypoint line!"); + + while (isspace(*buff)) buff++; + + parse_line(buff, WAYPT__OFS, "^", wpt); + + return wpt; +} + +static waypoint * +parse_trkpt(char *buff) +{ + garmin_fs_p gmsd; + waypoint *wpt; + + wpt = waypt_new(); + gmsd = garmin_fs_alloc(-1); + fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); + + parse_line(buff, TRKPT__OFS, ";", wpt); + + return wpt; +} + +/* + * parse_categories is currently only a dummy procedure. + * w'll need a central storage with binding to the module + * which has established a list of category names. + */ + +static void +parse_categories(char *buff) +{ + char *cin; + int cat = 0; + + while ((cin = csv_lineparse(buff, ",", "", cat++))) { + gbuint16 cx; + + buff = NULL; + + cin = lrtrim(cin); + if (*cin == 0) continue; + + garmin_fs_convert_category(cin, &cx); + } +} + + +/* main functions */ + +static void +rd_init(const char *fname) +{ + fin = gbfopen(fname, "rb", MYNAME); + + gardown = 1; + mode = wptdata; + grid = grid_lat_lon_dmm; + datum = DATUM_WGS84; + altf = 1; + event_ct = 0; +} + +static void +rd_deinit(void) +{ + gbfclose(fin); +} + +static void +data_read(void) +{ + char *buff; + int line = 0; + waypoint *wpt = NULL; + waypoint *prev = NULL; + route_head *head = NULL; + + while ((buff = gbfgetstr(fin))) { + char *cin = buff; + char *cdata; + + line++; + + cin = lrtrim(buff); + if (!*cin) continue; + + cdata = cin+1; + while (! isspace(*cdata)) cdata++; + while (isspace(*cdata)) cdata++; + if (! *cdata) continue; + + switch(*cin) { + + case '#': /* comment */ + break; + + case 'A': + if (case_ignore_strncmp(cdata, "Meter", 5) == 0) + altf = 1.0; + else if (case_ignore_strncmp(cdata, "Feet", 4) == 0) + altf = FEET_TO_METERS(1.0); + break; + + case 'C': /* categories */ + parse_categories(cdata); + break; + + case 'D': + datum = gt_lookup_datum_index(cdata, MYNAME); + break; + + case 'I': /* event point */ + wpt = waypt_new(); + cdata += parse_coordinates(cdata, datum, grid, + &wpt->latitude, &wpt->longitude, MYNAME); + xasprintf(&wpt->shortname, "Event%d", ++event_ct); + while (isspace(*cdata)) cdata++; + if (*cdata == ';') { + int dyn; + + cdata++; + wpt->icon_descr = gt_find_desc_from_icon_number( + atoi(cdata), PCX, &dyn); + wpt->wpt_flags.icon_descr_is_dynamic = dyn; + } + waypt_add(wpt); + break; + + case 'M': + grid = gt_lookup_grid_type(cdata, MYNAME); + break; + + case 'P': /* proximity waypoint */ + case 'W': /* normal waypoint */ + wpt = parse_waypt(cin + 3); + prev = wpt; + if (wpt) { + if (mode == rtedata) + route_add_wpt(head, wpt); + else + waypt_add(wpt); + } + break; + + case 'c': /* additional lines */ + switch(*(cin+1)) { + int index; + + case 'A': case 'B': + case 'C': case 'D': + + index = WPT_cA_OFS + ((*(cin+1) - 'A') * 256); + parse_line(cdata, index, "|", wpt); + break; + + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': + + index = WPT_c0_OFS + ((*(cin+1) - '0') * 256); + parse_line(cdata, index, ";", wpt); + break; + + case 'L': + waypt_add_url(wpt, xstrdup(cdata), NULL); + break; + + default: + break; + } + break; + + case 'N': /* track log header */ + mode = trkdata; + head = route_head_alloc(); + cdata = strchr(cdata, '-'); + if (cdata) { + while (isspace(*cdata)) cdata++; + if (*cdata) { + char *s; + s = strrchr(cdata, ','); + if (s) { + *s = '\0'; + s = strrchr(cdata, ','); + if (s) { + *s = '\0'; + head->rte_name = xstrdup(cdata); + } + } + } + } + track_add_head(head); + break; + + case 'R': /* route header */ + mode = rtedata; + head = route_head_alloc(); + cdata += 3; /*skip route number */ + if (*cdata) head->rte_name = xstrdup(cdata); + route_add_head(head); + break; + + case 'T': + wpt = parse_trkpt(cdata); + if (wpt) track_add_wpt(head, wpt); + break; + + case 'V': + if (strcmp(cin, G7T_HEADER) != 0) { + fatal(MYNAME ": Invalid version or invalid file!\n"); + } + gardown = 0; + break; + + default: + break; + } + } +} + +/* --------------------------------------------------------------------------- */ + +ff_vecs_t g7towin_vecs = { + ff_type_file, + { ff_cap_read, ff_cap_read, ff_cap_read }, + rd_init, + NULL, + rd_deinit, + NULL, + data_read, + NULL, + NULL, + g7towin_args, + CET_CHARSET_MS_ANSI, 0 +}; + +#endif /* CSVFMTS_ENABLED */ diff --git a/garmin.c b/garmin.c index 51517774b..c06f995dd 100644 --- a/garmin.c +++ b/garmin.c @@ -145,6 +145,7 @@ rw_init(const char *fname) case 155: /* Garmin V */ case 404: /* SP2720 */ + case 520: /* SP2820 */ receiver_short_length = 20; break; case 382: /* C320 */ @@ -420,6 +421,96 @@ route_read(void) } +#if 0 +static +void +lap_read_as_track(void) +{ + int32 ntracks; + GPS_PLap *array; + route_head *trk_head = NULL; + int trk_num = 0; + int index; + int i; + + ntracks = GPS_Command_Get_Lap(portname, &array, waypt_read_cb); + if ( ntracks <= 0 ) + return; + for (i = 0; i < ntracks; i++) { + waypoint *wpt; + if (array[i]->index == -1){ + index=i; + } else { + index=array[i]->index; + index=i; + } + + if ((trk_head == NULL) || (i == 0) || + /* D906 - last track:index is the track index */ + (array[i]->index == -1 && array[i]->track_index != 255) || + /* D10xx - no real separator, use begin/end time to guess */ + (abs(array[i-1]->start_time + array[i]->total_time/100-array[i]->start_time) > 2) + ) { + static struct tm * stmp; + stmp = gmtime(&array[i]->start_time); + trk_head = route_head_alloc(); + /*For D906, we would like to use the track_index in the last packet instead...*/ + trk_head->rte_num = ++trk_num; + trk_head->rte_name = xmalloc(32); + strftime(trk_head->rte_name, 32, "%Y-%m-%dT%H:%M:%SZ", stmp); + track_add_head(trk_head); + + wpt = waypt_new(); + + wpt->longitude = array[i]->begin_lon; + wpt->latitude = array[i]->begin_lat; + wpt->heartrate = array[i]->avg_heart_rate; + wpt->cadence = array[i]->avg_cadence; + wpt->speed = array[i]->max_speed; + wpt->creation_time = array[i]->start_time; + wpt->microseconds = 0; + + wpt->shortname = xmalloc(8); + sprintf(wpt->shortname, "#%d-0", index); + wpt->description = xmalloc(128); + sprintf(wpt->description, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d", + array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate, + array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method); + + track_add_wpt(trk_head, wpt); + } +/*Allow even if no correct location, no skip if invalid */ +/* if (array[i]->no_latlon) { +* continue; +* } +*/ + wpt = waypt_new(); + + wpt->longitude = array[i]->end_lon; + wpt->latitude = array[i]->end_lat; + wpt->heartrate = array[i]->avg_heart_rate; + wpt->cadence = array[i]->avg_cadence; + wpt->speed = array[i]->max_speed; + wpt->creation_time = array[i]->start_time + array[i]->total_time/100; + wpt->microseconds = 10000*(array[i]->total_time % 100); + /*Add fields with no mapping in the description */ + wpt->shortname = xmalloc(8); + sprintf(wpt->shortname, "#%d", index); + wpt->description = xmalloc(128); + sprintf(wpt->description, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)", + array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate, + array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method, + array[i]->begin_lon, array[i]->begin_lat); + + track_add_wpt(trk_head, wpt); + } + while(ntracks) { + GPS_Lap_Del(&array[--ntracks]); + } + xfree(array); +} +#endif + /* * Rather than propogate Garmin-specific data types outside of the Garmin * code, we convert the PVT (position/velocity/time) data from the receiver diff --git a/garmin_fs.c b/garmin_fs.c index 47afd54c8..3fa634eb4 100644 --- a/garmin_fs.c +++ b/garmin_fs.c @@ -27,6 +27,13 @@ #define MYNAME "garmin_fs" +#define GARMIN_GPX_EXT_REFERENCE \ + "xmlns:gpxx=\"" \ + "http://www.garmin.com/xmlschemas/GpxExtensions/v3\" " \ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " \ + "xsi:schemaLocation=\"http://www.garmin.com/xmlschemas/GpxExtensions/v3 " \ + "http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd" + garmin_fs_t * garmin_fs_alloc(const int protocol) { @@ -36,7 +43,7 @@ garmin_fs_alloc(const int protocol) result->fs.type = FS_GMSD; result->fs.copy = (fs_copy) garmin_fs_copy; result->fs.destroy = garmin_fs_destroy; - result->fs.convert = NULL; + result->fs.convert = garmin_fs_convert; result->fs.next = NULL; result->protocol = protocol; @@ -52,11 +59,16 @@ garmin_fs_destroy(void *fs) { garmin_ilink_t *ilinks; + if (data->addr != NULL) xfree(data->addr); + if (data->cc != NULL) xfree(data->cc); if (data->city != NULL) xfree(data->city); + if (data->country != NULL) xfree(data->country); + if (data->cross_road != NULL) xfree(data->cross_road); if (data->facility != NULL) xfree(data->facility); + if (data->phone_nr != NULL) xfree(data->phone_nr); + if (data->postal_code != NULL) xfree(data->postal_code); if (data->state != NULL) xfree(data->state); - if (data->cc != NULL) xfree(data->cc); - if (data->cross_road != NULL) xfree(data->cross_road); + if ((ilinks = data->ilinks) != NULL) { ilinks->ref_count--; if (ilinks->ref_count <= 0) { @@ -85,12 +97,30 @@ void garmin_fs_copy(garmin_fs_t **dest, garmin_fs_t *src) memcpy(*dest, src, sizeof(*src)); - (*dest)->city = (src->city != NULL) ? xstrdup(src->city) : NULL; - (*dest)->facility = (src->facility != NULL) ? xstrdup(src->facility) : NULL; - (*dest)->state = (src->state != NULL) ? xstrdup(src->facility) : NULL; + (*dest)->addr = (src->addr != NULL) ? xstrdup(src->addr) : NULL; (*dest)->cc = (src->cc != NULL) ? xstrdup(src->cc) : NULL; + (*dest)->city = (src->city != NULL) ? xstrdup(src->city) : NULL; + (*dest)->country = (src->country != NULL) ? xstrdup(src->country) : NULL; (*dest)->cross_road = (src->cross_road != NULL) ? xstrdup(src->cross_road) : NULL; - (*dest)->addr = (src->addr != NULL) ? xstrdup(src->addr) : NULL; + (*dest)->facility = (src->facility != NULL) ? xstrdup(src->facility) : NULL; + (*dest)->phone_nr = (src->phone_nr != NULL) ? xstrdup(src->phone_nr) : NULL; + (*dest)->postal_code = (src->postal_code != NULL) ? xstrdup(src->postal_code) : NULL; + (*dest)->state = (src->state != NULL) ? xstrdup(src->state) : NULL; +} + +void garmin_fs_convert(void *fs) +{ + garmin_fs_t *gmsd = (garmin_fs_t *) fs; + + if (gmsd->addr) gmsd->addr = cet_convert_string(gmsd->addr); + if (gmsd->cc) gmsd->cc = cet_convert_string(gmsd->cc); + if (gmsd->city) gmsd->city = cet_convert_string(gmsd->city); + if (gmsd->country) gmsd->country = cet_convert_string(gmsd->country); + if (gmsd->cross_road) gmsd->cross_road = cet_convert_string(gmsd->cross_road); + if (gmsd->facility) gmsd->facility = cet_convert_string(gmsd->facility); + if (gmsd->phone_nr) gmsd->phone_nr = cet_convert_string(gmsd->phone_nr); + if (gmsd->postal_code) gmsd->postal_code = cet_convert_string(gmsd->postal_code); + if (gmsd->state) gmsd->state = cet_convert_string(gmsd->state); } /* GPX - out */ @@ -98,29 +128,36 @@ void garmin_fs_copy(garmin_fs_t **dest, garmin_fs_t *src) void garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) { + char *phone, *addr; garmin_fs_t *gmsd = GMSD_FIND(waypt); + if (gmsd == NULL) return; - if ((gmsd->flags.category && gmsd->category) || - gmsd->flags.depth || - gmsd->flags.proximity || - gmsd->flags.temperature || - gmsd->flags.display) + addr = GMSD_GET(addr, ""); + if (! *addr) addr = GMSD_GET(city, ""); + if (! *addr) addr = GMSD_GET(country, ""); + if (! *addr) addr = GMSD_GET(postal_code, ""); + if (! *addr) addr = GMSD_GET(state, ""); + + phone = GMSD_GET(phone_nr, ""); + + if (*addr || *phone || + (gmsd->flags.category && gmsd->category) || + WAYPT_HAS(waypt, depth) || + WAYPT_HAS(waypt, proximity) || + WAYPT_HAS(waypt, temperature) || + gmsd->flags.display) { int space = 1; gbfprintf(ofd, "%*s\n", space++ * 2, ""); - gbfprintf(ofd, "%*s\n", space++ * 2, ""); - if (gmsd->flags.proximity) - gbfprintf(ofd, "%*s%.6f\n", space * 2, "", gmsd->proximity); - if (gmsd->flags.temperature) - gbfprintf(ofd, "%*s%.6f\n", space * 2, "", gmsd->temperature); - if (gmsd->flags.depth) - gbfprintf(ofd, "%*s%.6f\n", space * 2, "", gmsd->depth); + gbfprintf(ofd, "%*s\n", space++ * 2, "", GARMIN_GPX_EXT_REFERENCE); + if WAYPT_HAS(waypt, proximity) + gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->proximity); + if WAYPT_HAS(waypt, temperature) + gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->temperature); + if WAYPT_HAS(waypt, depth) + gbfprintf(ofd, "%*s%.6f\n", space * 2, "", waypt->depth); if (gmsd->flags.display) { char *cx; @@ -151,6 +188,27 @@ garmin_fs_xml_fprint(gbfile *ofd, const waypoint *waypt) } gbfprintf(ofd, "%*s\n", --space * 2, ""); } + if (*addr) { + char *str; + gbfprintf(ofd, "%*s\n", space++ * 2, ""); + + if ((str = GMSD_GET(addr, NULL))) + gbfprintf(ofd, "%*s%s\n", space * 2, "", str); + if ((str = GMSD_GET(city, NULL))) + gbfprintf(ofd, "%*s%s\n", space * 2, "", str); + if ((str = GMSD_GET(state, NULL))) + gbfprintf(ofd, "%*s%s\n", space * 2, "", str); + if ((str = GMSD_GET(country, NULL))) + gbfprintf(ofd, "%*s%s\n", space * 2, "", str); + if ((str = GMSD_GET(postal_code, NULL))) + gbfprintf(ofd, "%*s%s\n", space * 2, "", str); + + gbfprintf(ofd, "%*s\n", --space * 2, ""); + } + if (*phone) { + gbfprintf(ofd, "%*s%s\n", space * 2, "", phone); + } + gbfprintf(ofd, "%*s\n", --space * 2, ""); gbfprintf(ofd, "%*s\n", --space * 2, ""); } @@ -170,20 +228,32 @@ garmin_fs_xml_convert(const int base_tag, int tag, const char *cdatastr, waypoin tag -= base_tag; /* - tt_garmin_extension, -> 0 - tt_garmin_waypt_extension, -> 1 - tt_garmin_proximity, -> 2 - tt_garmin_temperature,-> 3 - tt_garmin_depth, -> 4 - tt_garmin_display_mode, -> 5 - tt_garmin_categories, -> 6 - tt_garmin_category, -> 7 + tt_garmin_waypt_extension, -> 0 + tt_garmin_proximity, -> 1 + tt_garmin_temperature,-> 2 + tt_garmin_depth, -> 3 + tt_garmin_display_mode, -> 4 + tt_garmin_categories, -> 5 + tt_garmin_category, -> 6 + tt_garmin_addr, -> 7 + tt_garmin_city, -> 8 + tt_garmin_state, -> 9 + tt_garmin_country, -> 10 + tt_garmin_postal_code, -> 11 + tt_garmin_phone_nr, -> 12 */ switch(tag) { - case 2: GMSD_SET(proximity, atof(cdatastr)); break; - case 3: GMSD_SET(temperature, atof(cdatastr)); break; - case 4: GMSD_SET(depth, atof(cdatastr)); break; - case 5: if (case_ignore_strcmp(cdatastr, "SymbolOnly") == 0) { + case 1: + if (*cdatastr) WAYPT_SET(waypt, proximity, atof(cdatastr)); + break; + case 2: + if (*cdatastr) WAYPT_SET(waypt, temperature, atof(cdatastr)); + break; + case 3: + if (*cdatastr) WAYPT_SET(waypt, depth, atof(cdatastr)); + break; + case 4: + if (case_ignore_strcmp(cdatastr, "SymbolOnly") == 0) { GMSD_SET(display, gt_display_mode_symbol); } else if (case_ignore_strcmp(cdatastr, "SymbolAndDescription") == 0) { @@ -193,9 +263,27 @@ garmin_fs_xml_convert(const int base_tag, int tag, const char *cdatastr, waypoin GMSD_SET(display, gt_display_mode_symbol_and_name); } break; - case 7: if ( ! garmin_fs_merge_category(cdatastr, waypt)) { + case 6: + if ( ! garmin_fs_merge_category(cdatastr, waypt)) warning(MYNAME ": Unable to convert category \"%s \"!\n", cdatastr); - } + break; + case 7: + GMSD_SETSTR(addr, cdatastr); + break; + case 8: + GMSD_SETSTR(city, cdatastr); + break; + case 9: + GMSD_SETSTR(state, cdatastr); + break; + case 10: + GMSD_SETSTR(country, cdatastr); + break; + case 11: + GMSD_SETSTR(postal_code, cdatastr); + break; + case 12: + GMSD_SETSTR(phone_nr, cdatastr); break; } } @@ -270,9 +358,9 @@ garmin_fs_garmin_after_read(const GPS_PWay way, waypoint *wpt, const int protoid /* flagged data fields */ GMSD_SET(display, gt_switch_display_mode_value(way->dspl, gps_waypt_type, 1)); if (way->category != 0) GMSD_SET(category, way->category); - if (way->dst < 1.0e25f) GMSD_SET(proximity, way->dst); - if (way->temperature_populated) GMSD_SET(temperature, way->temperature); - if (way->dpth < 1.0e25f) GMSD_SET(depth, way->dpth); + if (way->dst < 1.0e25f) WAYPT_SET(wpt, proximity, way->dst); + if (way->temperature_populated) WAYPT_SET(wpt, temperature, way->temperature); + if (way->dpth < 1.0e25f) WAYPT_SET(wpt, depth, way->dpth); GMSD_SETNSTR(cc, way->cc, sizeof(way->cc)); GMSD_SETNSTR(state, way->state, sizeof(way->state)); GMSD_SETSTR(city, way->city); @@ -294,9 +382,9 @@ garmin_fs_garmin_before_write(const waypoint *wpt, GPS_PWay way, const int proto way->dspl = gt_switch_display_mode_value( GMSD_GET(display, way->dspl), gps_waypt_type, 0); way->category = GMSD_GET(category, way->category); - way->dpth = GMSD_GET(depth, way->dpth); - way->dst = GMSD_GET(proximity, way->dpth); - way->temperature = GMSD_GET(temperature, way->temperature); + way->dpth = WAYPT_GET(wpt, depth, way->dpth); + way->dst = WAYPT_GET(wpt, proximity, way->dpth); + way->temperature = WAYPT_GET(wpt, temperature, way->temperature); GMSD_GETNSTR(cc, way->cc, sizeof(way->cc)); GMSD_GETNSTR(city, way->city, sizeof(way->city)); diff --git a/garmin_fs.h b/garmin_fs.h index f12a11a8e..c1999e1d9 100644 --- a/garmin_fs.h +++ b/garmin_fs.h @@ -38,6 +38,7 @@ /* macros */ #define GMSD_FIND(a) (garmin_fs_t *) fs_chain_find((a)->fs, FS_GMSD) +#define GMSD_HAS(a) (gmsd && gmsd->flags.a) /* GMSD_GET(a,b): a = any gmsd field, b = default value */ #define GMSD_GET(a,b) ((gmsd) && (gmsd->flags.a)) ? (gmsd->a) : (b) @@ -45,6 +46,9 @@ /* GMSD_SET(a,b): a = numeric gmsd field, b = numeric source */ #define GMSD_SET(a,b) if (gmsd) {gmsd->a = (b); gmsd->flags.a = 1; } +/* GMSD_UNSET(a): a = gmsd field */ +#define GMSD_UNSET(a) if (gmsd) { gmsd->flags.a = 0; } + /* GMSD_SETSTR(a,b): a = gmsd field, b = null terminated source */ #define GMSD_SETSTR(a,b) if (gmsd && (b) && (b)[0]) { gmsd->a = xstrdup((b)); gmsd->flags.a = 1; } @@ -56,7 +60,7 @@ typedef struct garmin_ilink_s { int ref_count; - double lat, lon; + double lat, lon, alt; struct garmin_ilink_s *next; } garmin_ilink_t; @@ -65,15 +69,18 @@ typedef struct { unsigned int wpt_class:1; unsigned int display:1; unsigned int category:1; - unsigned int depth:1; - unsigned int proximity:1; - unsigned int temperature:1; unsigned int city:1; unsigned int state:1; unsigned int facility:1; unsigned int cc:1; unsigned int cross_road:1; - unsigned int addr:1; + unsigned int addr:1; + unsigned int country:1; + unsigned int phone_nr:1; + unsigned int postal_code:1; +#ifdef GMSD_EXPERIMENTAL + unsigned int subclass:1; +#endif } garmin_fs_flags_t; typedef struct garmin_fs_s @@ -87,21 +94,25 @@ typedef struct garmin_fs_s int wpt_class; gbint32 display; gbint16 category; - double depth; /* depth in meters */ - double proximity; /* proximity distance in meters */ - double temperature; char *city; /* city name */ char *facility; /* facility name */ char *state; /* state */ char *cc; /* country code */ char *cross_road; /* Intersection road label */ char *addr; /* address + number */ + char *country; /* country */ + char *phone_nr; /* phone number */ + char *postal_code; /* postal code */ garmin_ilink_t *ilinks; +#ifdef GMSD_EXPERIMENTAL + char subclass[22]; +#endif } garmin_fs_t, *garmin_fs_p; garmin_fs_t *garmin_fs_alloc(const int protocol); void garmin_fs_destroy(void *fs); void garmin_fs_copy(garmin_fs_t **dest, garmin_fs_t *src); +void garmin_fs_convert(void *fs); char *garmin_fs_xstrdup(const char *src, size_t size); /* for GPX */ diff --git a/garmin_gpi.c b/garmin_gpi.c new file mode 100644 index 000000000..26536684e --- /dev/null +++ b/garmin_gpi.c @@ -0,0 +1,1207 @@ +/* + + Support for Garmin Points of Interest (.gpi files) + + Copyright (C) 2007 Olaf Klein, o.b.klein@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +/* + History: + + * 2007/05/18: initial release (only a reader) + * 2007/05/20: added writer code with embedded bitmap + * 2007/05/22: add support for multiple bounding boxes + (useful / required!) for large waypoints lists + * 2007/05/23: add optional user bitmap + * 2007/06/02: new method to compute center (mean) of bounds + avoid endless loop in group splitting + * 2007/07/10: put address fields (i.e. city) into GMSD + * 2007/07/12: add write support for new address fields + + ToDo: + + * Display mode ("Symbol & Name") ??? not in gpi ??? + * decode speed/proximity + * support category from GMSD "Garmin Special Data" +*/ + +#include "defs.h" +#include "cet_util.h" +#include "jeeps/gpsmath.h" +#include "garmin_fs.h" +#include "garmin_gpi.h" +#include +#include +#include +#include + +#define MYNAME "garmin_gpi" + +#define GPI_DBG 1 +#undef GPI_DBG + +#define DEFAULT_ICON "Waypoint" +#define WAYPOINTS_PER_BLOCK 128 + +/* flags used in the gpi address mask */ +#define GPI_ADDR_CITY 1 +#define GPI_ADDR_COUNTRY 2 +#define GPI_ADDR_STATE 4 +#define GPI_ADDR_POSTAL_CODE 8 +#define GPI_ADDR_ADDR 16 + +static char *opt_cat, *opt_pos, *opt_notes, *opt_hide_bitmap, *opt_descr, *opt_bitmap; + +static arglist_t garmin_gpi_args[] = { + {"bitmap", &opt_bitmap, "Use specified bitmap on output", + NULL, ARGTYPE_FILE, ARG_NOMINMAX}, + {"category", &opt_cat, "Default category on output", + "My points", ARGTYPE_STRING, ARG_NOMINMAX}, + {"hide", &opt_hide_bitmap, "Don't show gpi bitmap on device", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + {"descr", &opt_descr, "Write description to address field", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + {"notes", &opt_notes, "Write notes to address field", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + {"position", &opt_pos, "Write position to address field", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + ARG_TERMINATOR +}; + +typedef struct { + int D2; + char S3[9]; /* "GRMRECnn" */ + time_t crdate; /* creation date and time */ + char POI[4]; /* "POI" */ + char S8[3]; + char *group; + char *category; +} reader_data_t; + +typedef struct writer_data_s { + queue Q; + int ct; + int sz; + bounds bds; + struct writer_data_s *top_left; + struct writer_data_s *top_right; + struct writer_data_s *buttom_left; + struct writer_data_s *buttom_right; +} writer_data_t; + +typedef struct gpi_waypt_data_s { + int sz; + char *addr; + char *postal_code; +} gpi_waypt_data_t; + +typedef struct { + gbint32 size; + gbint16 res1; + gbint16 res2; + gbint32 image_offset; + gbint32 header_size; + gbint32 width; + gbint32 height; + gbint16 planes; + gbint16 bpp; + gbint32 compression_type; + gbint32 image_data_size; + gbint32 resolution_h; + gbint32 resolution_v; + gbint32 used_colors; + gbint32 important_colors; +} bmp_header_t; + +typedef struct { + gbint16 index; + gbint16 height; + gbint16 width; + gbint16 line_sz; + gbint16 bpp; + gbint16 fixed_0; + gbint32 image_size; + gbint32 fixed_2c; + gbint32 flag1; + gbint32 tr_color; + gbint32 flag2; + gbint32 size_2c; +} gpi_bitmap_header_t; + +typedef struct { + int sz; + short mask; + char addr_is_dynamic; + char *addr; + char *city; + char *country; + char *phone_nr; + char *postal_code; + char *state; +} gpi_waypt_t; + +static gbfile *fin, *fout; +static gbint32 codepage; /* code-page, i.e. 1252 */ +static reader_data_t *rdata; +static writer_data_t *wdata; +static short_handle short_h; + +#ifdef GPI_DBG +# define PP warning("@%1$6x (%1$8d): ", gbftell(fin)) +# define dbginfo warning +#else +# define PP +#endif + +/******************************************************************************* +* %%% gpi reader %%% * +*******************************************************************************/ + +/* look for or initialize GMSD */ +static garmin_fs_t * +gpi_gmsd_init(waypoint *wpt) +{ + garmin_fs_t *gmsd = GMSD_FIND(wpt); + if (wpt == NULL) { + fatal(MYNAME ": Error in file structure.\n"); + } + if (gmsd == NULL) { + gmsd = garmin_fs_alloc(-1); + fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); + } + return gmsd; +} + +/* read a standard string with or without 'EN' (or whatever) header */ +static char * +gpi_read_string(const char *field) +{ + int l1; + char *res = NULL; + + l1 = gbfgetint16(fin); + if (l1 > 0) { + short l2; + char first; + + first = gbfgetc(fin); + if (first == 0) { + char en[2]; + + is_fatal((gbfgetc(fin) != 0), + MYNAME ": Error reading field '%s'!", field); + + gbfread(en, 1, sizeof(en), fin); + l2 = gbfgetint16(fin); + is_fatal((l2 + 4 != l1), + MYNAME ": Error out of sync (wrong size %d/%d) on field '%s'!", l1, l2, field); + + if ((en[0] < 'A') || (en[0] > 'Z') || (en[1] < 'A') || (en[1] > 'Z')) + fatal(MYNAME ": Invalid country code!\n"); + res = xmalloc(l2 + 1); + res[l2] = '\0'; + PP; + if (l2 > 0) + gbfread(res, 1, l2, fin); + } + else { + res = xmalloc(l1 + 1); + *res = first; + *(res + l1) = '\0'; + PP; + l1--; + if (l1 > 0) + gbfread(res + 1, 1, l1, fin); + + } + } +#ifdef GPI_DBG + dbginfo("%s: %s\n", field, (res == NULL) ? "" : res); +#endif + return res; +} + +static void +read_header(void) +{ + int len, i; +#ifdef GPI_DBG + struct tm tm; + char stime[32]; +#endif + + i = gbfgetint32(fin); + if (i != 0) i = gbfgetint32(fin); + rdata->D2 = gbfgetint32(fin); + + gbfread(&rdata->S3, 1, sizeof(rdata->S3) - 1, fin); /* GRMRECnn */ + if (strncmp(rdata->S3, "GRMREC", 6) != 0) + fatal(MYNAME ": No GPI file!\n"); + + PP; + rdata->crdate = gbfgetint32(fin); +#ifdef GPI_DBG + tm = *localtime(&rdata->crdate); + tm.tm_year += 20; /* !!! */ + tm.tm_mday -= 1; /* !!! */ + strftime(stime, sizeof(stime), "%Y/%m/%d %H:%M:%S", &tm); + dbginfo("crdate = %lu (%s)\n", rdata->crdate, stime); +#endif + + (void) gbfgetint16(fin); /* 0 */ + + len = gbfgetint16(fin); + gbfseek(fin, len, SEEK_CUR); /* "my.gpi" */ + + (void) gbfgetint32(fin); /* 1 */ + (void) gbfgetint32(fin); /* 12 */ + + gbfread(&rdata->POI, 1, sizeof(rdata->POI) - 1, fin); + if (strcmp(rdata->POI, "POI") != 0) + fatal(MYNAME ": Wrong or unsupported GPI file!\n"); + + for (i = 0; i < 3; i++) (void)gbfgetc(fin); + gbfread(&rdata->S8, 1, sizeof(rdata->S8) - 1, fin); + + codepage = gbfgetint32(fin); + +#ifdef GPI_DBG + PP; + dbginfo("< leaving header\n"); +#endif +} + +/* gpi tag handler */ +static int read_tag(const char *caller, const int tag, waypoint *wpt); + + +/* read a single poi with all options */ +static void +read_poi(const int sz) +{ + int pos, len; + waypoint *wpt; + +#ifdef GPI_DBG + PP; + dbginfo("> reading poi (size %d)\n", sz); +#endif + PP; + len = gbfgetint32(fin); /* sub-header size */ +#ifdef GPI_DBG + dbginfo("poi sublen = %1$d (0x%1$x)\n", len); +#endif + pos = gbftell(fin); + + wpt = waypt_new(); + wpt->icon_descr = DEFAULT_ICON; + + wpt->latitude = GPS_Math_Semi_To_Deg(gbfgetint32(fin)); + wpt->longitude = GPS_Math_Semi_To_Deg(gbfgetint32(fin)); + + (void) gbfgetint16(fin); /* ? always 1 ? */ + (void) gbfgetc(fin); /* seems to 1 when extra options present */ + + wpt->shortname = gpi_read_string("Shortname"); + + while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) { + int tag = gbfgetint32(fin); + if (! read_tag("read_poi", tag, wpt)) break; + } + + if (wpt->notes && !wpt->description) wpt->description = xstrdup(wpt->notes); + if (wpt->description && !wpt->notes) wpt->notes = xstrdup(wpt->description); + + waypt_add(wpt); + +#ifdef GPI_DBG + PP; + dbginfo("< leaving poi\n"); +#endif +} + +/* read poi's following a group header */ +static void +read_poi_list(const int sz) +{ + int pos, i; + + pos = gbftell(fin); +#ifdef GPI_DBG + PP; + dbginfo("> reading poi list (-> %1$x / %1$d )\n", pos + sz); +#endif + PP; + i = gbfgetint32(fin); /* mostly 23 (0x17) */ +#ifdef GPI_DBG + dbginfo("list sublen = %1$d (0x%1$x)\n", i); +#endif + (void) gbfgetint32(fin); /* max-lat */ + (void) gbfgetint32(fin); /* max-lon */ + (void) gbfgetint32(fin); /* min-lat */ + (void) gbfgetint32(fin); /* min-lon */ + + (void) gbfgetc(fin); /* three unknown bytes */ + (void) gbfgetc(fin); /* ? should be zero ? */ + (void) gbfgetc(fin); + + (void) gbfgetint32(fin); /* ? const 0x1000100 ? */ + + while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) { + int tag = gbfgetint32(fin); + if (! read_tag("read_poi_list", tag, NULL)) return; + } +#ifdef GPI_DBG + PP; + dbginfo("< leaving poi list\n"); +#endif +} + + +static void +read_poi_group(const int sz, const int tag) +{ + int pos; + + pos = gbftell(fin); +#ifdef GPI_DBG + PP; + dbginfo("> reading poi group (-> %1$x / %1$d)\n", pos + sz); +#endif + if (tag == 0x80009) { + int subsz; + + PP; + subsz = gbfgetint32(fin); /* ? offset to category data ? */ +#ifdef GPI_DBG + dbginfo("group sublen = %d (-> %x / %d)\n", subsz, pos + subsz + 4, pos + subsz + 4); +#endif + } + if (rdata->group) xfree(rdata->group); /* currently unused */ + rdata->group = gpi_read_string("Group"); + + while (gbftell(fin) < (gbsize_t)(pos + sz)) { + int subtag = gbfgetint32(fin); + if (! read_tag("read_poi_group", subtag, NULL)) break; + } + +#ifdef GPI_DBG + PP; + dbginfo("< leaving poi group\n"); +#endif +} + + +/* gpi tag handler */ +static int +read_tag(const char *caller, const int tag, waypoint *wpt) +{ + int pos, sz; + short mask; + char *str; + garmin_fs_t *gmsd; + + sz = gbfgetint32(fin); + pos = gbftell(fin); + +#ifdef GPI_DBG + PP; + dbginfo("%s: tag = 0x%x (size %d)\n", caller, tag, sz); +#endif + if ((tag >= 0x80000) && (tag <= 0x800ff)) sz += 4; + + switch(tag) { + case 0x3: /* size = 12 ? sound */ + case 0x4: /* size = 2 ? */ + case 0x6: /* size = 2 ? */ + break; + + case 0x5: /* group bitmap */ + break; + + case 0x7: + (void) gbfgetint16(fin); /* category number */ + if (rdata->category) xfree(rdata->category); + rdata->category = gpi_read_string("Category"); + break; + + case 0xa: + wpt->description = gpi_read_string("Description"); + break; + + case 0xe: /* ? notes or description / or both ? */ + mask = gbfgetc(fin); + if (mask == 0x01) { + str = gpi_read_string("Notes"); + } + else if (mask == 0x32) { + str = gpi_read_string("Notes"); + } + else break; + + if (wpt->description) wpt->notes = str; + else wpt->description = str; + break; + + case 0x80002: + read_poi(sz); + break; + + case 0x80008: + read_poi_list(sz); + break; + + case 0x9: /* ? older versions / no category data ? */ + case 0x80009: /* current POI loader */ + read_poi_group(sz, tag); + break; + + case 0x8000b: /* address (street/city...) */ + (void) gbfgetint32(fin); + PP; + mask = gbfgetint16(fin); /* address fields mask */ +#ifdef GPI_DBG + dbginfo("GPI Address field mask: %d (0x%02x)\n", mask, mask); +#endif + if ((mask & GPI_ADDR_CITY) && (str = gpi_read_string("City"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(city, str); + } + if ((mask & GPI_ADDR_COUNTRY) && (str = gpi_read_string("Country"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(country, str); + } + if ((mask & GPI_ADDR_STATE) && (str = gpi_read_string("State"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(state, str); + } + if ((mask & GPI_ADDR_POSTAL_CODE) && (str = gpi_read_string("Postal code"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(postal_code, str); + } + if ((mask & GPI_ADDR_ADDR) && (str = gpi_read_string("Street address"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(addr, str); + } + break; + + case 0x8000c: /* phone-number */ + (void) gbfgetint32(fin); + PP; + + mask = gbfgetint16(fin); /* phone fields mask */ +#ifdef GPI_DBG + dbginfo("GPI Phone field mask: %d (0x%02x)\n", mask, mask); +#endif + if ((mask & 1) && (str = gpi_read_string("Phone"))) { + gmsd = gpi_gmsd_init(wpt); + GMSD_SET(phone_nr, str); + } + break; + + case 0x80012: /* ? sounds / images ? */ + break; + + default: + warning(MYNAME ": Unknown tag (0x%x). Please report!\n", tag); + return 0; + } + gbfseek(fin, pos + sz, SEEK_SET); + return 1; +} + +/******************************************************************************* +* %%% gpi writer %%% * +*******************************************************************************/ + +static void +write_string(const char *str, const char long_format) +{ + int len; + + len = strlen(str); + if (long_format) { + gbfputint32(len + 4, fout); + gbfwrite("EN", 1, 2, fout); + } + gbfputint16(len, fout); + gbfwrite(str, 1, len, fout); +} + + +static int +compare_wpt_cb(const queue *a, const queue *b) +{ + const waypoint *wa = (waypoint *) a; + const waypoint *wb = (waypoint *) b; + + return strcmp(wa->shortname, wb->shortname); +} + + +static char +compare_strings(const char *s1, const char *s2) +{ + if (s1 == s2) return 0; + else if (s1) { + if (s2) return strcmp(s1, s2); + else return 1; + } + else return 1; +} + + +static writer_data_t * +wdata_alloc() +{ + writer_data_t *res; + + res = xcalloc(1, sizeof(*res)); + QUEUE_INIT(&res->Q); + waypt_init_bounds(&res->bds); + + return res; +} + + +static void +wdata_free(writer_data_t *data) +{ + queue *elem, *tmp; + + QUEUE_FOR_EACH(&data->Q, elem, tmp) { + waypoint *wpt = (waypoint *)elem; + + if (wpt->extra_data) { + gpi_waypt_t *dt = (gpi_waypt_t *) wpt->extra_data; + if (dt->addr_is_dynamic) xfree(dt->addr); + xfree(dt); + } + waypt_free(wpt); + } + + if (data->top_left) wdata_free(data->top_left); + if (data->top_right) wdata_free(data->top_right); + if (data->buttom_left) wdata_free(data->buttom_left); + if (data->buttom_right) wdata_free(data->buttom_right); + + xfree(data); +} + + +static void +wdata_add_wpt(writer_data_t *data, waypoint *wpt) +{ + data->ct++; + ENQUEUE_TAIL(&data->Q, &wpt->Q); + waypt_add_to_bounds(&data->bds, wpt); +} + + +static void +wdata_check(writer_data_t *data) +{ + queue *elem, *tmp; + double center_lat, center_lon; + + if ((data->ct <= WAYPOINTS_PER_BLOCK) || + /* avoid endless loop for points (more than WAYPOINTS_PER_BLOCK) + at same coordinates */ + ((data->bds.min_lat >= data->bds.max_lat) && (data->bds.min_lon >= data->bds.max_lon))) { + if (data->ct > 1) + sortqueue(&data->Q, compare_wpt_cb); + return; + } + + /* compute the (mean) center of current bounds */ + + center_lat = center_lon = 0; + QUEUE_FOR_EACH(&data->Q, elem, tmp) { + waypoint *wpt = (waypoint *) elem; + center_lat += wpt->latitude; + center_lon += wpt->longitude; + } + center_lat /= data->ct; + center_lon /= data->ct; + + QUEUE_FOR_EACH(&data->Q, elem, tmp) { + waypoint *wpt = (waypoint *) elem; + writer_data_t **ref; + + if (wpt->latitude < center_lat) { + if (wpt->longitude < center_lon) + ref = &data->buttom_left; + else + ref = &data->buttom_right; + } else { + if (wpt->longitude < center_lon) + ref = &data->top_left; + else + ref = &data->top_right; + } + + if (*ref == NULL) *ref = wdata_alloc(); + + data->ct--; + dequeue(&wpt->Q); + + wdata_add_wpt(*ref, wpt); + } + + if (data->top_left) wdata_check(data->top_left); + if (data->top_right) wdata_check(data->top_right); + if (data->buttom_left) wdata_check(data->buttom_left); + if (data->buttom_right) wdata_check(data->buttom_right); +} + + +static int +wdata_compute_size(writer_data_t *data) +{ + queue *elem, *tmp; + int res; + + res = 23; /* bounds, ... of tag 0x80008 */ + + QUEUE_FOR_EACH(&data->Q, elem, tmp) { + waypoint *wpt = (waypoint *) elem; + gpi_waypt_t *dt; + garmin_fs_t *gmsd; + char *str; + + res += 12; /* tag/sz/sub-sz */ + res += 19; /* poi fixed size */ + res += strlen(wpt->shortname); + res += 10; /* tag(4) */ + + str = NULL; + if (opt_descr) { + if (wpt->description && *wpt->description) + str = xstrdup(wpt->description); + } + else if (opt_notes) { + if (wpt->notes && *wpt->notes) + str = xstrdup(wpt->notes); + } + else if (opt_pos) + str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', " ", 0); + + dt = xcalloc(1, sizeof(*dt)); + wpt->extra_data = dt; + + if (str) { + dt->addr_is_dynamic = 1; + dt->addr = str; + dt->mask |= GPI_ADDR_ADDR; + dt->sz += (8 + strlen(dt->addr)); + } + + if ((gmsd = GMSD_FIND(wpt))) { + if ((dt->mask == 0) && ((dt->addr = GMSD_GET(addr, NULL)))) { + dt->mask |= GPI_ADDR_ADDR; + dt->sz += (8 + strlen(dt->addr)); + } + if ((dt->city = GMSD_GET(city, NULL))) { + dt->mask |= GPI_ADDR_CITY; + dt->sz += (8 + strlen(dt->city)); + } + if ((dt->country = GMSD_GET(country, NULL))) { + dt->mask |= GPI_ADDR_COUNTRY; + dt->sz += (8 + strlen(dt->country)); + } + if ((dt->state = GMSD_GET(state, NULL))) { + dt->mask |= GPI_ADDR_STATE; + dt->sz += (8 + strlen(dt->state)); + } + if ((dt->postal_code = GMSD_GET(postal_code, NULL))) { + dt->mask |= GPI_ADDR_POSTAL_CODE; + dt->sz += (2 + strlen(dt->postal_code)); /* short form */ + } + + if ((dt->phone_nr = GMSD_GET(phone_nr, NULL))) + res += (12 + 4 + strlen(dt->phone_nr)); + } + if (dt->mask) dt->sz += 2; /* + mask (two bytes) */ + if (dt->sz) res += (dt->sz + 12); /* + header size */ + + str = wpt->description; + if (! str) str = wpt->notes; + if (str) res += (12 + 4 + strlen(str)); + } + + if (data->top_left) res += wdata_compute_size(data->top_left); + if (data->top_right) res += wdata_compute_size(data->top_right); + if (data->buttom_left) res += wdata_compute_size(data->buttom_left); + if (data->buttom_right) res += wdata_compute_size(data->buttom_right); + + data->sz = res; + + return res + 12; /* + 12 = caller needs info about tag header size */ +} + + +static void +wdata_write(const writer_data_t *data) +{ + queue *elem, *tmp; + + gbfputint32(0x80008, fout); + gbfputint32(data->sz, fout); + gbfputint32(23, fout); /* bounds + three bytes */ + + gbfputint32(GPS_Math_Deg_To_Semi(data->bds.max_lat), fout); + gbfputint32(GPS_Math_Deg_To_Semi(data->bds.max_lon), fout); + gbfputint32(GPS_Math_Deg_To_Semi(data->bds.min_lat), fout); + gbfputint32(GPS_Math_Deg_To_Semi(data->bds.min_lon), fout); + + gbfputc(0, fout); /* three unknown bytes */ + gbfputc(0, fout); /* ? should be zero ? */ + gbfputc(0, fout); + + gbfputint32(0x1000100, fout); /* ? const 0x1000100 ? */ + + QUEUE_FOR_EACH(&data->Q, elem, tmp) { + char *str; + int s0, s1; + waypoint *wpt = (waypoint *)elem; + gpi_waypt_t *dt = wpt->extra_data; + + str = wpt->description; + if (! str) str = wpt->notes; + + gbfputint32(0x80002, fout); + + s0 = s1 = 19 + strlen(wpt->shortname); + s0 += 10; /* tag(4) */ + if (str) s0 += (12 + 4 + strlen(str)); /* descr */ + if (dt->sz) s0 += (12 + dt->sz); /* address part */ + if (dt->phone_nr) s0 += (12 + 4 + strlen(dt->phone_nr)); + + gbfputint32(s0, fout); /* size of following data (tag) */ + gbfputint32(s1, fout); /* basic size (without options) */ + + gbfputint32(GPS_Math_Deg_To_Semi(wpt->latitude), fout); + gbfputint32(GPS_Math_Deg_To_Semi(wpt->longitude), fout); + + gbfputint16(1, fout); /* ? always 1 ? */ + gbfputc(0, fout); /* seems to be 1 when extra options present */ + + write_string(wpt->shortname, 1); + + gbfputint32(4, fout); /* tag(4) */ + gbfputint32(2, fout); /* ? always 2 == version ??? */ + if (opt_hide_bitmap) gbfputint16(0x3ff, fout); /* values != 0 hides the bitmap */ + else gbfputint16(0, fout); + + if (str) { + gbfputint32(0xa, fout); + gbfputint32(strlen(str) + 8, fout); /* string + string header */ + write_string(str, 1); + } + + if (dt->sz) { /* gpi address */ + gbfputint32(0x8000b, fout); + gbfputint32(dt->sz, fout); + gbfputint32(0x2, fout); /* ? always 2 ? */ + gbfputint16(dt->mask, fout); + if (dt->mask & GPI_ADDR_CITY) write_string(dt->city, 1); + if (dt->mask & GPI_ADDR_COUNTRY) write_string(dt->country, 1); + if (dt->mask & GPI_ADDR_STATE) write_string(dt->state, 1); + if (dt->mask & GPI_ADDR_POSTAL_CODE) write_string(dt->postal_code, 0); + if (dt->mask & GPI_ADDR_ADDR) write_string(dt->addr, 1); + } + + if (dt->phone_nr) { + gbfputint32(0x8000c, fout); + gbfputint32(strlen(dt->phone_nr) + 2 + 2, fout); + gbfputint32(0x2, fout); /* ? always 2 ? */ + gbfputint16(1, fout); /* mask */ + write_string(dt->phone_nr, 0); + } + } + + if (data->top_left) wdata_write(data->top_left); + if (data->top_right) wdata_write(data->top_right); + if (data->buttom_left) wdata_write(data->buttom_left); + if (data->buttom_right) wdata_write(data->buttom_right); +} + + +static void +write_category(const char *category, const char *image, const int image_sz) +{ + int sz; + + sz = wdata_compute_size(wdata); + sz += 8; /* string header */ + sz += strlen(opt_cat); + + gbfputint32(0x80009, fout); + if ((! opt_hide_bitmap) && image_sz) + gbfputint32(sz + image_sz + 8, fout); + else + gbfputint32(sz, fout); + gbfputint32(sz, fout); + write_string(opt_cat, 1); + + wdata_write(wdata); + + if ((! opt_hide_bitmap) && image_sz) { + gbfputint32(5, fout); + gbfputint32(image_sz, fout); + gbfwrite(image, 1, image_sz, fout); + } +} + + +static void +write_header(void) +{ + time_t time = gpsbabel_time; /* !!! ZERO during leaktest !!! */ + + if (time != 0) { + struct tm tm = *gmtime(&time); + tm.tm_year -= 20; + time = mkgmtime(&tm); + time += SECONDS_PER_DAY; + } + + gbfputint32(0, fout); + gbfputint32(0x16, fout); + gbfwrite("GRMREC00", 1, 8, fout); + gbfputint32(time, fout); + gbfputint16(0, fout); + gbfputint16(6, fout); + gbfwrite("my.gpi", 1, 6, fout); + gbfputint32(1, fout); + gbfputint32(0xc, fout); + gbfwrite("POI", 1, 3, fout); + gbfputc(0, fout); + gbfputc(0, fout); + gbfputc(0, fout); + gbfwrite("00", 1, 2, fout); + gbfputint32(codepage, fout); +} + + +static void +enum_waypt_cb(const waypoint *ref) +{ + waypoint *wpt; + char *str; + queue *elem, *tmp; + + QUEUE_FOR_EACH(&wdata->Q, elem, tmp) { + waypoint *cmp = (waypoint *) elem; + + /* sort out nearly equal waypoints */ + if ((compare_strings(cmp->shortname, ref->shortname) == 0) && + (cmp->latitude == ref->latitude) && + (cmp->longitude == ref->longitude) && + (compare_strings(cmp->description, ref->description) == 0) && + (compare_strings(cmp->notes, ref->notes) == 0)) return; + } + + wpt = waypt_dupe(ref); + + str = mkshort(short_h, wpt->shortname); + xfree(wpt->shortname); + wpt->shortname = str; + + wdata_add_wpt(wdata, wpt); +} + + +static void +load_bitmap_from_file(const char *fname, char **data, int *data_sz) +{ + gbfile *f; + int i, sz; + int dest_bpp; + int src_line_sz, dest_line_sz; + bmp_header_t src_h; + int *color_table = NULL; + gpi_bitmap_header_t *dest_h; + char *ptr; + + f = gbfopen_le(fname, "rb", MYNAME); + is_fatal(gbfgetint16(f) != 0x4d42, MYNAME ": No BMP image."); + + /* read a standard bmp file header */ + src_h.size = gbfgetint32(f); + src_h.res1 = gbfgetint16(f); + src_h.res2 = gbfgetint16(f); + src_h.image_offset = gbfgetint32(f); + src_h.header_size = gbfgetint32(f); + src_h.width = gbfgetint32(f); + src_h.height = gbfgetint32(f); + src_h.planes = gbfgetint16(f); + src_h.bpp = gbfgetint16(f); + src_h.compression_type = gbfgetint32(f); + src_h.image_data_size = gbfgetint32(f); + src_h.resolution_h = gbfgetint32(f); + src_h.resolution_v = gbfgetint32(f); + src_h.used_colors = gbfgetint32(f); + src_h.important_colors = gbfgetint32(f); + +#ifdef GPI_DBG + printf("data size: 0x%1$x (%1$d)\n", src_h.size); + printf("image data offset: 0x%1$x (%1$d)\n", src_h.image_offset); + printf("header size: 0x%1$x (%1$d)\n", src_h.header_size); + printf("image width: 0x%1$x (%1$d)\n", src_h.width); + printf("image height: 0x%1$x (%1$d)\n", src_h.height); + printf("number of planes: 0x%1$x (%1$d)\n", src_h.planes); + printf("bits per pixel: 0x%1$x (%1$d)\n", src_h.bpp); + printf("compression type: 0x%1$x (%1$d)\n", src_h.compression_type); + printf("image size: 0x%1$x (%1$d)\n", src_h.image_data_size); + printf("horizontal resolution: 0x%1$x (%1$d)\n", src_h.resolution_h); + printf("vertical resolution: 0x%1$x (%1$d)\n", src_h.resolution_v); + printf("number of colors: 0x%1$x (%1$d)\n", src_h.used_colors); + printf("important colors: 0x%1$x (%1$d)\n", src_h.important_colors); +#endif + /* sort out unsupported files */ + if (! ((src_h.width <= 24) && (src_h.height <= 24) && + (src_h.width > 0) && (src_h.height > 0))) + fatal(MYNAME ": Unsupported format (%dx%d)!\n", src_h.width, src_h.height); + if (! ((src_h.bpp == 8) || (src_h.bpp == 24) || (src_h.bpp == 32))) + fatal(MYNAME ": Unsupported color depth (%d)!\n", src_h.bpp); + if (! (src_h.compression_type == 0)) + fatal(MYNAME ": Sorry, we don't support compressed bitmaps.\n"); + + if (src_h.used_colors > 0) { + color_table = xmalloc(4 * src_h.used_colors); + gbfread(color_table, 1, 4 * src_h.used_colors, f); + for (i = 0; i < src_h.used_colors; i++) { + int color = color_table[i]; + /* swap blue and red value */ + color = (color >> 16) | (color << 16) | (color & 0x00ff00); + color_table[i] = color & 0xffffff; + } + } + + /* calculate line-size for source and destination */ + src_line_sz = (src_h.width * src_h.bpp) / 8; + src_line_sz = ((int)((src_line_sz + 3) / 4)) * 4; + + if (src_h.bpp == 24) dest_bpp = 32; + else dest_bpp = src_h.bpp; + + dest_line_sz = (src_h.width * dest_bpp) / 8; + dest_line_sz = ((int)((dest_line_sz + 3) / 4)) * 4; + + sz = sizeof(*dest_h) + (src_h.height * dest_line_sz); + if (src_h.used_colors) sz += (src_h.used_colors * 4); + + ptr = xmalloc(sz); + dest_h = (void *)ptr; + *data = ptr; + *data_sz = sz; + + le_write16(&dest_h->index, 0); + le_write16(&dest_h->height, src_h.height); + le_write16(&dest_h->width, src_h.width); + le_write16(&dest_h->line_sz, dest_line_sz); + le_write16(&dest_h->bpp, dest_bpp); + le_write16(&dest_h->fixed_0, 0); /* seems to be fixed */ + le_write32(&dest_h->image_size, dest_line_sz * src_h.height); + le_write32(&dest_h->fixed_2c, 0x2c); /* seems to be fixed */ + le_write32(&dest_h->flag1, (dest_bpp == 8) ? 0x100 : 0); + le_write32(&dest_h->tr_color, 0xff00ff); /* magenta = transparent color */ + le_write32(&dest_h->flag2, 0x1); /* ? enable transparent mode ? */ + le_write32(&dest_h->size_2c, (dest_line_sz * src_h.height) + 0x2c); + + /* copy and revert order of BMP lines */ + ptr = (void *)dest_h; + ptr += (sizeof(*dest_h) + (dest_line_sz * (src_h.height - 1))); + + if (src_h.bpp == 24) { + /* 24 bpp seems to be not supported, convert to 32 bpp */ + for (i = 0; i < src_h.height; i++) { + int j; + char *p = ptr; + + for (j = 0; j < src_h.width; j++) { + int color; + color = (gbint32)gbfgetint16(f) | (gbfgetc(f) << 16); + le_write32(p, color); + p += 4; + } + ptr -= dest_line_sz; + } + } + else for (i = 0; i < src_h.height; i++) { + gbfread(ptr, 1, src_line_sz, f); + ptr -= dest_line_sz; + } + + if (src_h.used_colors > 0) { + ptr = (void *)dest_h; + ptr += (sizeof(*dest_h) + (src_h.height * src_line_sz)); + + for (i = 0; i < src_h.used_colors; i++) { + le_write32(ptr, color_table[i]); + ptr += 4; + } + } + + if (color_table) xfree(color_table); + gbfclose(f); +} + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ + +static void +garmin_gpi_rd_init(const char *fname) +{ + char cp[8]; + + fin = gbfopen_le(fname, "rb", MYNAME); + rdata = xcalloc(1, sizeof(*rdata)); + + read_header(); + + if ((codepage >= 1250) && (codepage <= 1257)) { + snprintf(cp, sizeof(cp), "CP%d", codepage); + cet_convert_init(cp, 1); + } + else warning(MYNAME ": Unsupported code page (%d).\n", codepage); +} + + +static void +garmin_gpi_wr_init(const char *fname) +{ + char cp[8]; + cet_cs_vec_t *vec; + int i; + + fout = gbfopen_le(fname, "wb", MYNAME); + + short_h = mkshort_new_handle(); + + setshort_length(short_h, 1024); + setshort_badchars(short_h, "\r\n"); + setshort_mustupper(short_h, 0); + setshort_mustuniq(short_h, 1); + setshort_whitespace_ok(short_h, 1); + setshort_repeating_whitespace_ok(short_h, 0); + setshort_defname(short_h, "POI"); + + codepage = 0; + + for (i = 1250; i <= 1257; i++) { + snprintf(cp, sizeof(cp), "CP%d", i); + vec = cet_find_cs_by_name(cp); + if (vec == global_opts.charset) { + codepage = i; + break; + } + } + + if (! codepage) { + warning(MYNAME ": Unsupported character set (%s)!\n", global_opts.charset_name); + fatal(MYNAME ": Valid values are CP1250 to CP1257.\n"); + } + + wdata = wdata_alloc(); +} + + +static void +garmin_gpi_rd_deinit(void) +{ + if (rdata->category) xfree(rdata->category); + if (rdata->group) xfree(rdata->group); + xfree(rdata); + gbfclose(fin); +} + + +static void +garmin_gpi_wr_deinit(void) +{ + wdata_free(wdata); + mkshort_del_handle(&short_h); + gbfclose(fout); +} + + +static void +garmin_gpi_read(void) +{ + while (1) { + int tag = gbfgetint32(fin); + if (tag == 0xffff) return; + if (! read_tag("garmin_gpi_read", tag, NULL)) return; + }; +} + + +static void +garmin_gpi_write(void) +{ + char *image; + int image_sz; + + if (strlen(opt_cat) == 0) fatal(MYNAME ": Can't write empty category!\n"); + + if (opt_hide_bitmap) { + image = NULL; + image_sz = 0; + } + else if (opt_bitmap && *opt_bitmap) + load_bitmap_from_file(opt_bitmap, &image, &image_sz); + else { + image = gpi_bitmap; /* embedded GPSBabel icon in gpi format */ + image_sz = GPI_BITMAP_SIZE; + } + waypt_disp_all(enum_waypt_cb); + + wdata_check(wdata); + write_header(); + write_category(opt_cat, image, image_sz); + + gbfputint32(0xffff, fout); /* final tag */ + gbfputint32(0, fout); /* ? dummy size ? */ + + if (image != gpi_bitmap) xfree(image); +} + +/**************************************************************************/ + +ff_vecs_t garmin_gpi_vecs = { + ff_type_file, + { + ff_cap_read | ff_cap_write /* waypoints */, + ff_cap_none /* tracks */, + ff_cap_none /* routes */ + }, + garmin_gpi_rd_init, + garmin_gpi_wr_init, + garmin_gpi_rd_deinit, + garmin_gpi_wr_deinit, + garmin_gpi_read, + garmin_gpi_write, + NULL, + garmin_gpi_args, + CET_CHARSET_MS_ANSI, 0 /* WIN-CP1252 */ +}; + +/**************************************************************************/ diff --git a/garmin_gpi.h b/garmin_gpi.h new file mode 100644 index 000000000..8c2bab369 --- /dev/null +++ b/garmin_gpi.h @@ -0,0 +1,112 @@ +#ifndef GARMIN_GPI_H +#define GARMIN_GPI_H + +static char gpi_bitmap[] = { + 0x00,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x08,0x00,0x00,0x00,0x40,0x02,0x00,0x00, + 0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0xff,0x00,0xff,0x00,0x01,0x00,0x00,0x00, + 0x6c,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x7e,0x7e,0x7e, + 0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e, + 0x7e,0x7e,0x00,0x7e,0x00,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, + 0x7f,0x7f,0x59,0x67,0x65,0x7f,0x7f,0x7f,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f, + 0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x74,0x3d,0x42,0x56,0x7e,0x7e,0x7f, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, + 0x7f,0x72,0x38,0x49,0x47,0x7e,0x7e,0x7f,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f, + 0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7d,0x37,0x47,0x7d,0x7e,0x7e,0x7f, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f, + 0x7f,0x7d,0x37,0x47,0x7d,0x7e,0x7e,0x7f,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f, + 0x7f,0x7f,0x7f,0x7f,0x7f,0x7c,0x6c,0x50,0x44,0x5e,0x4f,0x76,0x7e,0x7f,0x7f,0x7f, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x77,0x7e,0x7f,0x7f,0x7e,0x62,0x0d,0x00,0x05, + 0x10,0x08,0x09,0x59,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x29,0x1c, + 0x4c,0x7f,0x7f,0x60,0x02,0x0c,0x2a,0x37,0x51,0x63,0x57,0x15,0x58,0x7e,0x7e,0x7f, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x68,0x5a,0x41,0x5f,0x5f,0x07,0x0e,0x3d,0x41,0x41, + 0x4d,0x55,0x6b,0x61,0x26,0x57,0x57,0x2b,0x2f,0x30,0x00,0x7e,0x00,0x7e,0x77,0x7d, + 0x4e,0x3d,0x3d,0x16,0x35,0x41,0x7d,0x49,0x18,0x48,0x52,0x54,0x5b,0x31,0x31,0x63, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x40,0x7d,0x75,0x47,0x47,0x41,0x35,0x40,0x72,0x1e, + 0x7c,0x5d,0x1d,0x20,0x49,0x3d,0x3d,0x5b,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x60,0x5c, + 0x7a,0x1a,0x1a,0x3b,0x38,0x5d,0x0e,0x59,0x7d,0x3c,0x72,0x37,0x78,0x60,0x60,0x28, + 0x4f,0x71,0x00,0x7e,0x00,0x7e,0x7e,0x43,0x33,0x69,0x69,0x17,0x22,0x7d,0x2c,0x27, + 0x2a,0x2b,0x7d,0x32,0x61,0x4f,0x4f,0x36,0x3f,0x4c,0x00,0x7e,0x00,0x7e,0x7f,0x7e, + 0x3a,0x2b,0x2b,0x45,0x1a,0x40,0x47,0x7d,0x37,0x41,0x12,0x25,0x5e,0x46,0x46,0x4d, + 0x62,0x53,0x00,0x7e,0x00,0x7e,0x7f,0x7e,0x73,0x71,0x71,0x6a,0x13,0x39,0x1b,0x45, + 0x62,0x50,0x3a,0x7e,0x7e,0x7b,0x7b,0x5c,0x5b,0x49,0x00,0x7e,0x00,0x7e,0x7f,0x7e, + 0x59,0x01,0x01,0x06,0x64,0x35,0x4e,0x3e,0x26,0x21,0x66,0x7f,0x45,0x04,0x04,0x11, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7e,0x59,0x01,0x01,0x06,0x64,0x35,0x4e,0x3e, + 0x26,0x21,0x66,0x7f,0x45,0x04,0x04,0x11,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7e, + 0x7c,0x0a,0x0a,0x0f,0x65,0x7d,0x74,0x71,0x7c,0x7e,0x7e,0x7e,0x58,0x03,0x03,0x2b, + 0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f,0x7f,0x6d,0x6d,0x6f,0x2d,0x1d,0x63,0x7a, + 0x7e,0x75,0x5d,0x19,0x32,0x70,0x70,0x6f,0x7f,0x7f,0x00,0x7e,0x00,0x7e,0x7f,0x7f, + 0x7f,0x7f,0x7f,0x7e,0x7d,0x53,0x35,0x0b,0x1f,0x0e,0x34,0x5a,0x7f,0x7f,0x7f,0x7f, + 0x7f,0x7f,0x00,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x7f,0x7e,0x7e,0x7e, + 0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e,0x7e, + 0x7e,0x7e,0x7e,0x7e,0x0a,0x0a,0x0a,0x00,0x0b,0x0b,0x0b,0x00,0x16,0x16,0x16,0x00, + 0x1f,0x1f,0x1f,0x00,0x28,0x28,0x28,0x00,0x2d,0x2d,0x2d,0x00,0x35,0x35,0x35,0x00, + 0x3d,0x3d,0x3d,0x00,0x40,0x40,0x40,0x00,0x41,0x41,0x41,0x00,0x43,0x43,0x43,0x00, + 0x46,0x46,0x46,0x00,0x47,0x47,0x47,0x00,0x4b,0x4b,0x4b,0x00,0x4e,0x4e,0x4e,0x00, + 0x53,0x53,0x53,0x00,0x54,0x54,0x54,0x00,0x56,0x56,0x56,0x00,0x59,0x59,0x59,0x00, + 0x5a,0x5a,0x5a,0x00,0x5f,0x5f,0x5f,0x00,0x60,0x60,0x60,0x00,0x62,0x62,0x62,0x00, + 0x63,0x63,0x63,0x00,0x6a,0x6a,0x6a,0x00,0x74,0x74,0x74,0x00,0x75,0x75,0x75,0x00, + 0x76,0x76,0x76,0x00,0x78,0x78,0x78,0x00,0x79,0x79,0x79,0x00,0x7a,0x7a,0x7a,0x00, + 0x7c,0x7c,0x7c,0x00,0x7d,0x7d,0x7d,0x00,0x7e,0x7e,0x7e,0x00,0x80,0x80,0x80,0x00, + 0x81,0x81,0x81,0x00,0x82,0x82,0x82,0x00,0x83,0x83,0x83,0x00,0x84,0x84,0x84,0x00, + 0x85,0x85,0x85,0x00,0x87,0x87,0x87,0x00,0x88,0x88,0x88,0x00,0x89,0x89,0x89,0x00, + 0x8a,0x8a,0x8a,0x00,0x8b,0x8b,0x8b,0x00,0x8e,0x8e,0x8e,0x00,0x90,0x90,0x90,0x00, + 0x91,0x91,0x91,0x00,0x92,0x92,0x92,0x00,0x94,0x94,0x94,0x00,0x95,0x95,0x95,0x00, + 0x96,0x96,0x96,0x00,0x97,0x97,0x97,0x00,0x98,0x98,0x98,0x00,0x9b,0x9b,0x9b,0x00, + 0x9c,0x9c,0x9c,0x00,0x9d,0x9d,0x9d,0x00,0xa0,0xa0,0xa0,0x00,0xa1,0xa1,0xa1,0x00, + 0xa2,0xa2,0xa2,0x00,0xa4,0xa4,0xa4,0x00,0xa6,0xa6,0xa6,0x00,0xa7,0xa7,0xa7,0x00, + 0xab,0xab,0xab,0x00,0xac,0xac,0xac,0x00,0xad,0xad,0xad,0x00,0xae,0xae,0xae,0x00, + 0xaf,0xaf,0xaf,0x00,0xb0,0xb0,0xb0,0x00,0xb1,0xb1,0xb1,0x00,0xb2,0xb2,0xb2,0x00, + 0xb3,0xb3,0xb3,0x00,0xb4,0xb4,0xb4,0x00,0xb5,0xb5,0xb5,0x00,0xb6,0xb6,0xb6,0x00, + 0xb7,0xb7,0xb7,0x00,0xb9,0xb9,0xb9,0x00,0xbb,0xbb,0xbb,0x00,0xbc,0xbc,0xbc,0x00, + 0xbe,0xbe,0xbe,0x00,0xbf,0xbf,0xbf,0x00,0xc0,0xc0,0xc0,0x00,0xc1,0xc1,0xc1,0x00, + 0xc2,0xc2,0xc2,0x00,0xc3,0xc3,0xc3,0x00,0xc4,0xc4,0xc4,0x00,0xc5,0xc5,0xc5,0x00, + 0xc9,0xc9,0xc9,0x00,0xcb,0xcb,0xcb,0x00,0xcc,0xcc,0xcc,0x00,0xce,0xce,0xce,0x00, + 0xcf,0xcf,0xcf,0x00,0xd0,0xd0,0xd0,0x00,0xd1,0xd1,0xd1,0x00,0xd2,0xd2,0xd2,0x00, + 0xd4,0xd4,0xd4,0x00,0xd5,0xd5,0xd5,0x00,0xd6,0xd6,0xd6,0x00,0xd9,0xd9,0xd9,0x00, + 0xda,0xda,0xda,0x00,0xdb,0xdb,0xdb,0x00,0xdc,0xdc,0xdc,0x00,0xdd,0xdd,0xdd,0x00, + 0xe0,0xe0,0xe0,0x00,0xe1,0xe1,0xe1,0x00,0xe2,0xe2,0xe2,0x00,0xe3,0xe3,0xe3,0x00, + 0xe4,0xe4,0xe4,0x00,0xe6,0xe6,0xe6,0x00,0xe8,0xe8,0xe8,0x00,0xe9,0xe9,0xe9,0x00, + 0xea,0xea,0xea,0x00,0xeb,0xeb,0xeb,0x00,0xec,0xec,0xec,0x00,0xed,0xed,0xed,0x00, + 0xee,0xee,0xee,0x00,0xf0,0xf0,0xf0,0x00,0xf3,0xf3,0xf3,0x00,0xf4,0xf4,0xf4,0x00, + 0xf5,0xf5,0xf5,0x00,0xf7,0xf7,0xf7,0x00,0xf8,0xf8,0xf8,0x00,0xf9,0xf9,0xf9,0x00, + 0xfa,0xfa,0xfa,0x00,0xfb,0xfb,0xfb,0x00,0xfc,0xfc,0xfc,0x00,0xff,0xff,0xff,0x00, + 0xff,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 +}; + +#define GPI_BITMAP_SIZE sizeof(gpi_bitmap) + +#endif diff --git a/garmin_tables.c b/garmin_tables.c index a82369967..3bae4469c 100644 --- a/garmin_tables.c +++ b/garmin_tables.c @@ -21,6 +21,8 @@ */ #include "garmin_tables.h" +#include "jeeps/gpsmath.h" + #include #include @@ -182,7 +184,10 @@ icon_mapping_t garmin_icon_table[] = { * .... * { -2, 8192, "Custom 511" }, */ - +#if 0 +/* Since Garmin is busily adding icons to new units, we have to hide + * these so we can pass them through to the new entries. 6/2/07 robertl + */ { 92, 8227, "Micro-Cache" }, /* icon for "Toll Booth" */ { 48, 161, "Virtual cache" }, /* icon for "Scenic Area" */ { 86, 8217, "Multi-Cache" }, /* icon for "Stadium" */ @@ -191,7 +196,7 @@ icon_mapping_t garmin_icon_table[] = { { 83, 8214, "Post Office" }, /* Icon for "Post Office" */ { 47, 160, "Event Cache" }, /* Icon for "Event" */ { 90, 8221, "Webcam Cache" }, /* Icon for "Live Theatre" */ - +#endif /* MapSource V6.x */ { 140, 8286, "Flag, Red" }, @@ -597,6 +602,49 @@ char *gt_display_mode_names[] = { "Symbol & Description" }; +typedef struct { + char *shortname; + char *longname; + grid_type grid; +} grid_mapping_t; + +/* gt_mps_grid_names: !!! degree sign substituted with '*' !!! */ + +grid_mapping_t gt_mps_grid_names[] = +{ + { "ddd", "Lat/Lon hddd.ddddd*", grid_lat_lon_ddd }, + { "dmm", "Lat/Lon hddd*mm.mmm'", grid_lat_lon_dmm }, + { "dms", "Lat/Lon hddd*mm'ss.s\"", grid_lat_lon_dms }, + { "bng", "British National Grid", grid_bng }, + { "utm", "UTM", grid_utm }, + { NULL, NULL, 0 } +}; + +/* gt_mps_datum_names: */ + +typedef struct { + char *jeeps_name; + char *mps_name; +} datum_mapping_t; + +/* will be continued (when requested) */ +datum_mapping_t gt_mps_datum_names[] = +{ + { "Alaska-NAD27", "NAD27 Alaska" }, + { "Bahamas NAD27", "NAD27 Bahamas" }, + { "Canada_Mean(NAD27)", "NAD27 Canada" }, + { "Canal_Zone_(NAD27)", "NAD27 Canal Zone" }, + { "Carribean NAD27", "NAD27 Caribbean" }, + { "Cent America NAD27", "NAD27 Central" }, + { "Cuba NAD27", "NAD27 Cuba" }, + { "Geodetic Datum 49", "Geodetic Datum '49" }, + { "Greenland NAD27", "NAD27 Greenland" }, + { "Mexico NAD27", "NAD27 Mexico" }, + { "North America 83", "NAD83" }, + { "OSGB36", "Ord Srvy Grt Britn" }, + { NULL, NULL } +}; + unsigned char gt_switch_display_mode_value(const unsigned char display_mode, const int protoid, const char device) { @@ -834,6 +882,77 @@ gt_get_icao_cc(const char *country, const char *shortname) return NULL; } +grid_type +gt_lookup_grid_type(const char *grid_name, const char *module) +{ + grid_mapping_t *g; + + for (g = gt_mps_grid_names; (g->shortname); g++) { + if ((case_ignore_strcmp(grid_name, g->shortname) == 0) || + (case_ignore_strcmp(grid_name, g->longname) == 0)) + return g->grid; + } + + fatal("%s: Unsupported grid (%s)! See GPSBabel help for supported grids.\n", + module, grid_name); + + return grid_unknown; /* (warnings) */ +} + +char * +gt_get_mps_grid_longname(const grid_type grid, const char *module) +{ + if ((grid < GRID_INDEX_MIN) || (grid > GRID_INDEX_MAX)) + fatal("%s: Grid index out of range %d (%d..%d)!", + module, (int) grid, + (int)GRID_INDEX_MIN, (int)GRID_INDEX_MAX); + return gt_mps_grid_names[grid].longname; +} + +char * +gt_get_mps_datum_name(const int datum_index) +{ + char *result; + datum_mapping_t *d; + + result = GPS_Math_Get_Datum_Name(datum_index); + + for (d = gt_mps_datum_names; (d->jeeps_name); d++) + if (case_ignore_strcmp(result, d->jeeps_name) == 0) return d->mps_name; + + return result; +} + +int +gt_lookup_datum_index(const char *datum_str, const char *module) +{ + datum_mapping_t *d; + int result; + const char *name = datum_str; + + for (d = gt_mps_datum_names; (d->jeeps_name); d++) { + if (case_ignore_strcmp(name, d->mps_name) == 0) { + name = d->jeeps_name; + break; + } + } + + result = GPS_Lookup_Datum_Index(name); + + if (result < 0) { + char *tmp; + xasprintf(&tmp, "%s mean", datum_str); + result = GPS_Lookup_Datum_Index(tmp); + xfree(tmp); + } + + is_fatal(result < 0, + "%s: Unsupported datum (%s)! See GPSBabel help for supported datums.", + module, datum_str); + + return result; +} + #if MAKE_TABLE /* diff --git a/garmin_tables.h b/garmin_tables.h index 79667843c..c846c94c5 100644 --- a/garmin_tables.h +++ b/garmin_tables.h @@ -92,4 +92,9 @@ unsigned char gt_convert_category(const char *name, int *category); unsigned char gt_switch_display_mode_value(const unsigned char display_mode, const int protoid, const char device); +grid_type gt_lookup_grid_type(const char *grid_name, const char *module); +char *gt_get_mps_grid_longname(const grid_type grid, const char *module); +int gt_lookup_datum_index(const char *datum_str, const char *module); +char *gt_get_mps_datum_name(const int datum_index); + #endif diff --git a/garmin_txt.c b/garmin_txt.c index d1dc1eb79..97f7716c9 100644 --- a/garmin_txt.c +++ b/garmin_txt.c @@ -54,7 +54,7 @@ static int waypoints; static int routepoints; static waypoint **wpt_a; static int wpt_a_ct; -static int grid_index; +static grid_type grid_index; static int datum_index; static char *datum_str; static int current_line; @@ -139,26 +139,6 @@ static char *headers[] = { NULL }; -static char *grid_short_names[] = { - "ddd", - "dmm", - "dms", - "bng", - NULL -}; - -static char *grid_long_names[] = { /* starting at index !!! 3 !!! after inbuild lat/lon ... grids */ - "British National Grid", - NULL -}; - -#define GRID_IDX_LAT_LON_DDD 0 -#define GRID_IDX_LAT_LON_DMM 1 -#define GRID_IDX_LAT_LON_DMS 2 -#define GRID_IDX_BNG 3 - -#define GRID_IDX_MAX GRID_IDX_BNG - /* helpers */ static char * @@ -231,7 +211,7 @@ convert_datum(waypoint *wpt, const int to_internal_wgs84, double *dest_lat, doub { double alt; - if (datum_index == 118 /* WGS 84 */) { + if (datum_index == DATUM_WGS84 ) { if (to_internal_wgs84 == 0) { *dest_lat = wpt->latitude; *dest_lon = wpt->longitude; @@ -337,10 +317,10 @@ print_position(const waypoint *wpt) { int valid; double lat, lon, north, east; - char map[3]; char latsig, lonsig; double latmin, lonmin, latsec, lonsec; - int latint, lonint; + int latint, lonint, zone; + char map[3], zonec; convert_datum((waypoint *)wpt, 0, &lat, &lon); @@ -361,32 +341,43 @@ print_position(const waypoint *wpt) switch(grid_index) { - case GRID_IDX_LAT_LON_DDD: + case grid_lat_lon_ddd: gbfprintf(fout, "%c%0.*f %c%0.*f\t", latsig, precision, fabs(lat), lonsig, precision, fabs(lon)); break; - case GRID_IDX_LAT_LON_DMM: + case grid_lat_lon_dmm: gbfprintf(fout, "%c%d %0*.*f %c%d %0*.*f\t", latsig, latint, precision + 3, precision, latmin, lonsig, lonint, precision + 3, precision, lonmin); break; - case GRID_IDX_LAT_LON_DMS: + case grid_lat_lon_dms: gbfprintf(fout, "%c%d %d %.*f %c%d %d %.*f\t", latsig, latint, (int)latmin, precision, latsec, lonsig, lonint, (int)lonmin, precision, lonsec); break; - case GRID_IDX_BNG: + case grid_bng: + valid = GPS_Math_WGS84_To_UKOSMap_M(wpt->latitude, wpt->longitude, &east, &north, map); is_fatal(! valid, MYNAME ": Some (or all?) of the coordinates cannot be displayed using \"BNG\"."); - gbfprintf(fout, "%s %5.0f %5.0f", map, east, north); + gbfprintf(fout, "%s %5.0f %5.0f\t", map, east, north); break; + + case grid_utm: + + valid = GPS_Math_Known_Datum_To_UTM_EN(lat, lon, + &east, &north, &zone, &zonec, datum_index); + gbfprintf(fout, "%02d %c %.0f %.0f\t", zone, zonec, east, north); + break; + + default: + fatal("ToDo\n"); } } @@ -505,7 +496,7 @@ print_speed(double *distance, time_t *time) idist = si_round(dist); if ((*time != 0) && (idist > 0)) { - double speed = dist / (double)*time * SECONDS_PER_HOUR / 1000; + double speed = MPS_TO_KPH(dist / (double)*time); int ispeed = si_round(speed); if (speed < (double)0.01) @@ -585,17 +576,17 @@ write_waypt(const waypoint *wpt) print_distance(wpt->altitude, 1, 0); gbfprintf(fout, "\t"); - x = GMSD_GET(depth, unknown_alt); + x = WAYPT_GET(wpt, depth, unknown_alt); if (x != unknown_alt) print_distance(x, 1, 0); gbfprintf(fout, "\t"); - x = GMSD_GET(proximity, unknown_alt); + x = WAYPT_GET(wpt, proximity, unknown_alt); if (x != unknown_alt) print_distance(x, 0, 0); gbfprintf(fout, "\t"); - x = GMSD_GET(temperature, unknown_alt); + x = WAYPT_GET(wpt, temperature, unknown_alt); if (x != unknown_alt) { if (gtxt_flags.celsius) gbfprintf(fout, "%.f C", x); @@ -759,42 +750,25 @@ garmin_txt_wr_init(const char *fname) datum_str = get_option_val(opt_datum, NULL); grid_str = get_option_val(opt_grid, NULL); - grid_index = -1; - if (grid_str == NULL) { - grid_index = 1; /* default: dmm */ - } - else if (! sscanf(grid_str, "%d", &grid_index)) { - char *name; - int index; + grid_index = grid_lat_lon_dmm; + if (grid_str != NULL) { + int i; - index = 0; - while ((name = grid_short_names[index])) { - if (case_ignore_strcmp(name, grid_str) == 0) { - grid_index = index; - break; - } - index++; - } - if (name == NULL) { /* look in "long names" */ - index = 0; - while ((name = grid_long_names[index])) { - if (case_ignore_strcmp(name, grid_str) == 0) break; - else index++; - } - is_fatal(name == NULL, - MYNAME ": Unsupported grid (%s). See GPSBabel help for supported grids.", grid_str); - grid_index = 3 + index; + if (sscanf(grid_str, "%d", &i)) { + grid_index = (grid_type) i; + if ((grid_index < GRID_INDEX_MIN) || (grid_index > GRID_INDEX_MAX)) + fatal(MYNAME ": Grid index out of range (%d..%d)!", + (int)GRID_INDEX_MIN, (int)GRID_INDEX_MAX); } + else grid_index = gt_lookup_grid_type(grid_str, MYNAME); } - else is_fatal(grid_index > GRID_IDX_MAX, MYNAME ": Grid index out of range (0..%d)!", GRID_IDX_MAX); switch(grid_index) { - case GRID_IDX_BNG: /* force datum to "Ord Srvy Grt Britn" */ - datum_index = GPS_Lookup_Datum_Index("OSGB36"); + case grid_bng: /* force datum to "Ord Srvy Grt Britn" */ + datum_index = DATUM_OSGB36; break; default: - datum_index = GPS_Lookup_Datum_Index(datum_str); - is_fatal(datum_index < 0, MYNAME ": Invalid or unknown gps datum (%s)!", datum_str); + datum_index = gt_lookup_datum_index(datum_str, MYNAME); } if (opt_utc != NULL) { @@ -817,22 +791,14 @@ garmin_txt_wr_deinit(void) static void garmin_txt_write(void) { - switch(grid_index) { - case 0: - cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\tLat/Lon hddd.ddddd%c\r\n", 0xB0); - break; - case 1: - cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\tLat/Lon hddd%cmm.mmm'\r\n", 0xB0); - break; - case 2: - cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\tLat/Lon hddd%cmm'ss.s\"\r\n", 0xB0); - break; - case GRID_IDX_BNG: - cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\t%s\r\n", grid_long_names[0]); - datum_str = "Ord Srvy Grt Britn"; - break; - } + char *grid_str, *c; + grid_str = xstrdup(gt_get_mps_grid_longname(grid_index, MYNAME)); + while ((c = strchr(grid_str, '*'))) *c = 0xB0; /* degree sign */ + cet_gbfprintf(fout, &cet_cs_vec_cp1252, "Grid\t%s\r\n", grid_str); + xfree(grid_str); + + datum_str = gt_get_mps_datum_name(datum_index); gbfprintf(fout, "Datum\t%s\r\n\r\n", datum_str); waypoints = 0; @@ -904,47 +870,14 @@ free_header(const header_type ht) /* data parsers */ +#if 0 +/* moved to util.c */ static void parse_position(const char *str, waypoint *wpt) { - double lat, lon; - unsigned char lathemi, lonhemi; - int deg_lat, deg_lon, min_lat, min_lon; - char map[3]; - - switch(grid_index) { - - case GRID_IDX_LAT_LON_DDD: - sscanf(str, "%c%lf %c%lf", &lathemi, &lat, &lonhemi, &lon); - break; - - case GRID_IDX_LAT_LON_DMM: - sscanf(str, "%c%d %lf %c%d %lf", &lathemi, °_lat, &lat, &lonhemi, °_lon, &lon); - lat = (double)deg_lat + (lat / (double)60); - lon = (double)deg_lon + (lon / (double)60); - break; - case GRID_IDX_LAT_LON_DMS: - sscanf(str, "%c%d %d %lf %c%d %d %lf", &lathemi, °_lat, &min_lat, &lat, &lonhemi, °_lon, &min_lon, &lon); - lat = (double)deg_lat + ((double)min_lat / (double)60) + (lat / (double)3600.0); - lon = (double)deg_lon + ((double)min_lon / (double)60) + (lon / (double)3600.0); - break; - - case GRID_IDX_BNG: - sscanf(str, "%2s %lf %lf", map, &lat, &lon); - lathemi = lonhemi = '\0'; - break; - } - - if (lathemi == 'S') - wpt->latitude = -lat; - else - wpt->latitude = lat; - - if (lonhemi == 'W') - wpt->longitude = -lon; - else - wpt->longitude = lon; +...... } +#endif static int parse_distance(const char *str, double *value) @@ -1026,7 +959,7 @@ parse_categories(const char *str) cin = lrtrim(cin); if (*cin != '\0') { if (!garmin_fs_convert_category(cin, &val)) - warning(MYNAME ": Unable to convert category \"%s\" at line %d!", cin, current_line); + warning(MYNAME ": Unable to convert category \"%s\" at line %d!\n", cin, current_line); else res = res | val; } @@ -1138,25 +1071,12 @@ static void parse_grid(void) { char *str = csv_lineparse(NULL, "\t", "", 1); - grid_index = -1; if (str != NULL) { - if (strstr(str, "dd.ddddd") != 0) grid_index = GRID_IDX_LAT_LON_DDD; - else if (strstr(str, "mm.mmm") != 0) grid_index = GRID_IDX_LAT_LON_DMM; - else if (strstr(str, "mm'ss.s") != 0) grid_index = GRID_IDX_LAT_LON_DMS; - else { - char *name; - int index = 0; - - while ((name = grid_long_names[index])) { - if (case_ignore_strcmp(name, str) == 0) { - grid_index = GRID_IDX_BNG + index; - break; - } - index++; - } - } - is_fatal(grid_index < 0, MYNAME ": Unsupported grid (%s)!", str); + if (strstr(str, "dd.ddddd") != 0) grid_index = grid_lat_lon_ddd; + else if (strstr(str, "mm.mmm") != 0) grid_index = grid_lat_lon_dmm; + else if (strstr(str, "mm'ss.s") != 0) grid_index = grid_lat_lon_dms; + else grid_index = gt_lookup_grid_type(str, MYNAME); } else fatal(MYNAME ": Missing grid headline!\n"); @@ -1167,10 +1087,8 @@ parse_datum(void) { char *str = csv_lineparse(NULL, "\t", "", 1); - if (str != NULL) { - datum_index = GPS_Lookup_Datum_Index(str); - is_fatal(datum_index < 0, MYNAME ": Unsupported GPS datum \"%s\"!", str); - } + if (str != NULL) + datum_index = gt_lookup_datum_index(str, MYNAME); else fatal(MYNAME ": Missing GPS datum headline!\n"); } @@ -1206,11 +1124,14 @@ parse_waypoint(void) } } break; - case 4: parse_position(str, wpt); break; + case 4: + parse_coordinates(str, datum_index, grid_index, + &wpt->latitude, &wpt->longitude, MYNAME); + break; case 5: if (parse_distance(str, &d)) wpt->altitude = d; break; - case 6: if (parse_distance(str, &d)) GMSD_SET(depth, d); break; - case 7: if (parse_distance(str, &d)) GMSD_SET(proximity, d); break; - case 8: if (parse_temperature(str, &d)) GMSD_SET(temperature, d); break; + case 6: if (parse_distance(str, &d)) WAYPT_SET(wpt, depth, d); break; + case 7: if (parse_distance(str, &d)) WAYPT_SET(wpt, proximity, d); break; + case 8: if (parse_temperature(str, &d)) WAYPT_SET(wpt, temperature, d); break; case 9: if (parse_display(str, &i)) GMSD_SET(display, i); break; case 10: break; /* skip color */ case 11: @@ -1222,14 +1143,16 @@ parse_waypoint(void) case 12: GMSD_SETSTR(facility, str); break; case 13: GMSD_SETSTR(city, str); break; case 14: GMSD_SETSTR(state, str); break; - case 15: GMSD_SETSTR(cc, gt_get_icao_cc(str, wpt->shortname)); break; + case 15: + GMSD_SETSTR(country, str); + GMSD_SETSTR(cc, gt_get_icao_cc(str, wpt->shortname)); + break; case 16: parse_date_and_time(str, &wpt->creation_time); break; case 17: wpt->url = DUPSTR(str); break; case 18: GMSD_SET(category, parse_categories(str)); break; default: break; } } - convert_datum(wpt, 1, NULL, NULL); waypt_add(wpt); } @@ -1311,12 +1234,13 @@ parse_track_waypoint(void) while ((str = csv_lineparse(NULL, "\t", "", column++))) { int field_no = header_fields[trkpt_header][column]; switch(field_no) { - case 1: parse_position(str, wpt); break; + case 1: parse_coordinates(str, datum_index, grid_index, + &wpt->latitude, &wpt->longitude, MYNAME); + break; case 2: parse_date_and_time(str, &wpt->creation_time); break; case 3: parse_distance(str, &wpt->altitude); break; } } - convert_datum(wpt, 1, NULL, NULL); route_add_wpt(current_trk, wpt); } diff --git a/gbfile.c b/gbfile.c index e86c491ec..3b3489e2a 100644 --- a/gbfile.c +++ b/gbfile.c @@ -503,7 +503,7 @@ gbftell(gbfile *file) #if !ZLIB_INHIBITED gbsize_t result = gztell(file->handle.gz); if (file->back != -1) { - file->back = -1; +// file->back = -1; result--; } return result; @@ -565,18 +565,25 @@ gbfeof(gbfile *file) int gbfungetc(const int c, gbfile *file) { - int r = -1; + int res; + if (file->gzapi) { #if !ZLIB_INHIBITED - file->back = -1; + if (file->back == -1) { + file->back = c; + res = c; + } + else { + fatal(MYNAME ": Cannot store more than one byte back!\n"); + } #else fatal(NO_ZLIB); #endif } else { - r = ungetc(c, file->handle.std); + res = ungetc(c, file->handle.std); } - return r; + return res; } /* GPSBabel 'file' enhancements */ diff --git a/gbser.c b/gbser.c index 0daff0d79..a43777c5a 100644 --- a/gbser.c +++ b/gbser.c @@ -137,7 +137,7 @@ int gbser_read_wait(void *handle, void *buf, unsigned len, unsigned ms) { * none are available. */ int gbser_readc(void *handle) { - char buf; + unsigned char buf; int rc; rc = gbser_read(handle, &buf, 1); @@ -154,7 +154,7 @@ int gbser_readc(void *handle) { * milliseconds for a character to be available. */ int gbser_readc_wait(void *handle, unsigned ms) { - char buf; + unsigned char buf; int rc; rc = gbser_read_wait(handle, &buf, 1, ms); diff --git a/gbser_posix.c b/gbser_posix.c index 69f310b30..c2c6cab3c 100644 --- a/gbser_posix.c +++ b/gbser_posix.c @@ -117,10 +117,14 @@ void *gbser_init(const char *port_name) { h->magic = MYMAGIC; h->vmin = h->vtime = 0; - if (h->fd = open(port_name, O_RDWR | O_NOCTTY), h->fd == -1) { + if (0 == strcmp(port_name, "-")) { + h->fd = 0; + return h; + } + else if (h->fd = open(port_name, O_RDWR | O_NOCTTY), h->fd == -1) { gbser__db(1, "Failed to open port (%s)\n", strerror(errno)); - goto failed; - } + goto failed; + } if (!isatty(h->fd)) { gbser__db(1, "%s is not a TTY\n"); @@ -393,12 +397,12 @@ const char *fix_win_serial_name(const char *comname) { /* Read from the serial port until the specified |eol| character is * found. Any character matching |discard| will be discarded. To - * read lines terminated by 0x0A0x0D discarding linefeeds use + * read lines terminated by 0x0A, 0x0D discarding linefeeds use * gbser_read_line(h, buf, len, 1000, 0x0D, 0x0A); + * The terminating character and any discarded characters are not + * stored in the buffer. */ -int gbser_read_line(void *handle, void *buf, - unsigned len, unsigned ms, - int eol, int discard) { +int gbser_read_line(void *handle, void *buf, unsigned len, unsigned ms, int eol, int discard) { char *bp = buf; unsigned pos = 0; hp_time tv; diff --git a/gbversion.h b/gbversion.h index 76e859083..bcd591b2e 100644 --- a/gbversion.h +++ b/gbversion.h @@ -4,5 +4,5 @@ * * Isn't simplification via automation grand? */ -#define VERSION "1.3.3" +#define VERSION "1.3.4" diff --git a/gcdb.c b/gcdb.c index aeb6723f1..0509e6546 100644 --- a/gcdb.c +++ b/gcdb.c @@ -21,8 +21,7 @@ #include "defs.h" #if PDBFMTS_ENABLED -#include "coldsync/palm.h" -#include "coldsync/pdb.h" +#include "pdbfile.h" #define MYNAME "GeocachingDB" #define MYTYPE 0x44415441 /* DATA */ @@ -48,11 +47,9 @@ struct dbrec { struct dbfld dbfld[1]; }; -static FILE *file_in; -static FILE *file_out; +static pdbfile *file_in, *file_out; static const char *out_fname; -static struct pdb *opdb; -static struct pdb_record *opdb_rec; +static int ct; static char *tbuf = NULL; static char *tbufp = NULL; @@ -60,26 +57,27 @@ static char *tbufp = NULL; static void rd_init(const char *fname) { - file_in = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); } static void rd_deinit(void) { - fclose(file_in); + pdb_close(file_in); } static void wr_init(const char *fname) { - file_out = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); out_fname = fname; + ct = 0; } static void wr_deinit(void) { - fclose(file_out); + pdb_close(file_out); if ( tbuf ) xfree(tbuf); } @@ -87,18 +85,13 @@ wr_deinit(void) static void data_read(void) { - struct pdb *pdb; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; - if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed\n"); - } - - if ((pdb->creator != MYCREATOR) || (pdb->type != MYTYPE)) { + if ((file_in->creator != MYCREATOR) || (file_in->type != MYTYPE)) { fatal(MYNAME ": Not a GeocachingDB file.\n"); } - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) { + for(pdb_rec = file_in->rec_list; pdb_rec; pdb_rec=pdb_rec->next) { waypoint *wpt = waypt_new(); struct dbrec *rec = (struct dbrec *) pdb_rec->data; int nflds; @@ -182,8 +175,6 @@ data_read(void) wpt->longitude = lon_dir * (lon_deg + lon_min/60); waypt_add(wpt); } - - free_pdb(pdb); } @@ -236,7 +227,6 @@ static void gcdb_write_wpt(const waypoint *wpt) { struct dbrec *rec; - static int ct; int reclen; char tbuf[100]; @@ -294,39 +284,23 @@ gcdb_write_wpt(const waypoint *wpt) */ reclen = gcdb_add_to_rec(rec, NULL, 0, NULL); - opdb_rec = new_Record(0, 2, ct++, (uword) reclen, (const ubyte *)rec); - - if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record\n"); - } - - if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record\n"); - } - + pdb_write_rec(file_out, 0, 2, ct++, rec, reclen); xfree(rec); } static void data_write(void) { - - if (NULL == (opdb = new_pdb())) { - fatal (MYNAME ": new_pdb failed\n"); - } - - strncpy(opdb->name, out_fname, PDB_DBNAMELEN); - strncpy(opdb->name, "GeocachingDB", PDB_DBNAMELEN); - opdb->name[PDB_DBNAMELEN-1] = 0; - opdb->attributes = PDB_ATTR_BACKUP; - opdb->ctime = opdb->mtime = current_time() + 2082844800U; - opdb->type = MYTYPE; /* CWpt */ - opdb->creator = MYCREATOR; /* cGPS */ - opdb->version = 1; + strncpy(file_out->name, out_fname, PDB_DBNAMELEN); + strncpy(file_out->name, "GeocachingDB", PDB_DBNAMELEN); + file_out->name[PDB_DBNAMELEN-1] = 0; + file_out->attr = PDB_FLAG_BACKUP; + file_out->ctime = file_out->mtime = current_time() + 2082844800U; + file_out->type = MYTYPE; /* CWpt */ + file_out->creator = MYCREATOR; /* cGPS */ + file_out->version = 1; waypt_disp_all(gcdb_write_wpt); - - pdb_Write(opdb, fileno(file_out)); } diff --git a/gdb.c b/gdb.c index e2c23825c..e6fc0190c 100644 --- a/gdb.c +++ b/gdb.c @@ -1,7 +1,7 @@ -/* +/* Garmin GPS Database Reader/Writer - Copyright (C) 2005-2007 Olaf Klein, o.b.klein@gpsbabel.org + Copyright (C) 2005,2006,2007 Olaf Klein, o.b.klein@gpsbabel.org Mainly based on mapsource.c, Copyright (C) 2005 Robert Lipe, robertlipe@usa.net @@ -53,6 +53,10 @@ 2006/11/01: Use version of GPSBabel and date/time of gdb.c (managed by CVS) for watermark 2007/01/23: add support for GDB version 3 2007/02/07: Add special code for unknown bytes in waypoints with class GE 8 (calculated points) + 2007/02/15: Nearly full rewrite. Full support for GDB V3. New option roadbook. + 2007/05/03: Add code for tricky V3 descriptions + 2007/06/18: Tweak some forgotten "flagged" fields + 2007/07/07: Better support for new fields since V3 (postal code/street address/instruction) */ #include @@ -61,1166 +65,1056 @@ #include #include "defs.h" + +#include "cet.h" +#include "cet_util.h" +#include "csv_util.h" +#include "garmin_fs.h" #include "garmin_tables.h" +#include "grtcirc.h" #include "jeeps/gpsmath.h" -#include "garmin_fs.h" -#include "cet_util.h" #define MYNAME "gdb" -#undef GDB_DEBUG +#define GDB_VER_1 1 +#define GDB_VER_2 2 +#define GDB_VER_3 3 -#define GDB_VER_MIN 1 -#define GDB_VER_MAX 2 +#define GDB_VER_UTF8 GDB_VER_3 +#define GDB_VER_MIN GDB_VER_1 +#define GDB_VER_MAX GDB_VER_3 -#define GDB_DEFAULTWPTCLASS 0 -#define GDB_HIDDENROUTEWPTCLASS 8 +#define GDB_DEF_CLASS gt_waypt_class_user_waypoint +#define GDB_DEF_HIDDEN_CLASS gt_waypt_class_map_point +#define GDB_DEF_ICON 18 #define GDB_NAME_BUFFERLEN 1024 -#define GDB_URL_BUFFERLEN 4096 /* Safety first */ -#define GDB_NOTES_BUFFERLEN 4096 /* (likewise) */ -#define DEFAULTICONVALUE 18 +#define GDB_DBG_WPT 1 +#define GDB_DBG_RTE 2 +#define GDB_DBG_TRK 4 -#ifdef UTF8_SUPPORT -# define GDB_UTF8_ENABLED 1 -#else -# define GDB_UTF8_ENABLED 0 -#endif +#define GDB_DBG_WPTe 8 +#define GDB_DBG_RTEe 16 +#define GDB_DBG_TRKe 32 -/* %%% local vars %%% */ +#define GDB_DEBUG (GDB_DBG_WPTe) /* | GDB_DBG_RTE) */ +#undef GDB_DEBUG +// #define GDB_DEBUG 0xff -/* static char gdb_release[] = "$Revision: 1.48 $"; */ -static char gdb_release_date[] = "$Date: 2007/02/20 20:51:15 $"; +#define DBG(a,b) if ((GDB_DEBUG & (a)) && (b)) -static FILE *fin, *fout; -static char *fin_name, *fout_name; +/*******************************************************************************/ -static int gdb_ver = 1; -static int gdb_debug = 0; -static int gdb_via; /* 0 = read and write hidden points too; 1 = drop */ -static int gdb_category; +/* static char gdb_release[] = "$Revision: 1.58 $"; */ +static char gdb_release_date[] = "$Date: 2007/07/14 21:06:14 $"; -static queue gdb_hidden; -static short_handle gdb_short_handle; +static gbfile *fin, *fout; +static int gdb_ver, gdb_category, gdb_via, gdb_roadbook; -#define GDB_OPT_VER "ver" -#define GDB_OPT_VIA "via" -#define GDB_OPT_CATEGORY "cat" +static queue wayptq_in, wayptq_out, wayptq_in_hidden; +static short_handle short_h; -static char *gdb_opt_category = NULL; -static char *gdb_opt_ver = NULL; -static char *gdb_opt_via = NULL; +static char *gdb_opt_category; +static char *gdb_opt_ver; +static char *gdb_opt_via; +static char *gdb_opt_roadbook; -static arglist_t gdb_args[] = { - {GDB_OPT_CATEGORY, &gdb_opt_category, - "Default category on output (1..16)", NULL, ARGTYPE_INT, "1", "16"}, - {GDB_OPT_VER, &gdb_opt_ver, - "Version of gdb file to generate (1,2)", "2", ARGTYPE_INT, "1", "2"}, - {GDB_OPT_VIA, &gdb_opt_via, - "Drop route points that do not have an equivalent waypoint (hidden points)", NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, - ARG_TERMINATOR -}; +static int waypt_flag; +static int route_flag; + +static int waypt_ct; /* informational: total number of waypoints in/out */ +static int waypth_ct; /* informational: total number of hidden waypoints in/out */ +static int rtept_ct; /* informational: total number of route points in/out */ +static int trkpt_ct; /* informational: total number of track points in/out */ +static int rte_ct; /* informational: total number of routes in/out */ +static int trk_ct; /* informational: total number of tracks in/out */ -/********************************************************************************************************/ +/*******************************************************************************/ -/* %%% 1-1 functions from mapsource, should by shared!!! %%% */ +#define ELEMENTS(a) a->rte_waypt_ct +#define NOT_EMPTY(a) (a && *a) -static waypoint * -gdb_find_wpt_q_by_name(const queue *whichQueue, const char *name) +static void +gdb_flush_waypt_queue(queue *Q) { queue *elem, *tmp; - waypoint *waypointp; - QUEUE_FOR_EACH(whichQueue, elem, tmp) { - waypointp = (waypoint *) elem; - if (0 == case_ignore_strcmp(waypointp->shortname, name)) { - return waypointp; - } + QUEUE_FOR_EACH(Q, elem, tmp) { + waypoint *wpt = (waypoint *)elem; + dequeue(elem); + if (wpt->extra_data) + xfree(wpt->extra_data); + waypt_free(wpt); } - return NULL; } -static int -gdb_detect_rtept_class(const waypoint *wpt) + +#if GDB_DEBUG +static void +disp_summary(const gbfile *f) { - if (gdb_find_wpt_q_by_name((queue *)&gdb_hidden, wpt->shortname) == NULL) - return (int)GDB_HIDDENROUTEWPTCLASS; - else - return (int)GDB_DEFAULTWPTCLASS; -} + int i, len; + + len = strlen(f->name); + + warning(MYNAME ": ====================="); + for (i = 0; i < len; i++) warning("="); + warning("\n" MYNAME ": %s summary for \"%s\"\n", + (f->mode == 'r') ? "Reader" : "Writer", f->name); + warning(MYNAME ": ---------------------"); + for (i = 0; i < len; i++) warning("-"); -/* %%% local functions (read support) %%% */ + warning("\n" MYNAME ": %d waypoint(s)\n", waypt_ct - waypth_ct); + warning(MYNAME ": %d hidden waypoint(s)\n", waypth_ct); + warning(MYNAME ": %d route(s) with total %d point(s)\n", rte_ct, rtept_ct); + warning(MYNAME ": %d track(s) with total %d point(s)\n", trk_ct, trkpt_ct); + warning(MYNAME ": ---------------------"); -#ifdef GDB_DEBUG -static void -gdb_print_buff(const char *buff, int count, const char *comment) -{ - int i; - printf(MYNAME ": dump of %s : ", comment); - for (i = 0; i < count; i++) - { - printf("%02x ", buff[i] & 0xFF); - } - printf("\n"); - fflush(stdout); + for (i = 0; i < len; i++) warning("-"); + warning("\n"); } +#else +#define disp_summary(a) #endif -static waypoint * -gdb_create_rte_wpt(const char *name, double lat, double lon, double alt) +/*******************************************************************************/ +/* TOOLS AND MACROS FOR THE READER */ +/*-----------------------------------------------------------------------------*/ + +#define FREAD_C gbfgetc(fin) +#define FREAD(a,b) gbfread(a,(b),1,fin) +#define FREAD_i32 gbfgetint32(fin) +#define FREAD_i16 gbfgetint16(fin) +#define FREAD_STR(a) gdb_fread_str(a,sizeof(a),fin) +#define FREAD_CSTR gdb_fread_cstr(fin) +#define FREAD_DBL gbfgetdbl(fin) +#define FREAD_LATLON GPS_Math_Semi_To_Deg(gbfgetint32(fin)) + +#if GDB_DEBUG +static char * +nice(const char *str) { - waypoint *wpt; + char *res, *env; + cet_cs_vec_t *vec; - wpt = find_waypt_by_name(name); - if (wpt == NULL) - { - if (gdb_via != 0) return NULL; - wpt = gdb_find_wpt_q_by_name((queue *)&gdb_hidden, name); - } - if (wpt != NULL) - { - wpt = waypt_dupe(wpt); -// wpt->creation_time = 0; /* !!! should be removed !!! */ - } - else - { - wpt = waypt_new(); - wpt->shortname = xstrdup(name); - wpt->latitude = lat; - wpt->longitude = lon; - wpt->altitude = alt; - wpt->depth = unknown_alt; + if (!(str && *str)) return ""; + + env = getenv("LANG"); + if (env == NULL) return (char *)str; + + if ((res = strchr(env, '.'))) env = ++res; + vec = cet_find_cs_by_name(env); + + if ((vec != NULL) && (vec != global_opts.charset)) { + static char buf[128]; + res = cet_str_any_to_any(str, global_opts.charset, vec); + strncpy(buf, res, sizeof(buf)); + xfree(res); + return buf; } - return wpt; + else return (char *)str; } +#endif -static size_t -gdb_fread(void *target, size_t size) +static char * +gdb_fread_cstr(gbfile *fin) { - size_t result; - - result = fread(target, 1, size, fin); - if (result < size) - { - if (feof(fin) != 0) - fatal(MYNAME ": unexpected end of file \"%s\"!\n", fin_name); - else - fatal(MYNAME ": I/O error occured during read from \"%s\"!\n", fin_name); + char *result = gbfgetcstr(fin); + + if (result && (*result == '\0')) { + xfree(result); + result = NULL; } return result; } static int -gdb_fread_str(char *dest, size_t maxlen) +gdb_fread_str(char *buf, int size, gbfile *fin) { - int c; + char c; int res = 0; - while (maxlen-- > 0) - { - c = fgetc(fin); - if ( c != EOF ) - { - if (c < 0) - fatal(MYNAME ": I/O error (%d) while read from \"%s\"!\n", +c, fin_name); - *dest++ = c; - if ( c == 0 ) return res; + while (size--) { + gbfread(&c, 1, 1, fin); + buf[res] = c; + if (c == '\0') return res; res++; - } - else - { - *dest++ = '\0'; - return res; - } } - fatal(MYNAME ": local buffer overflow detected, please report!\n"); - return 0; + buf[res] = '\0'; + return res; } -static int -gdb_fread_le(void *dest, size_t size, const unsigned int bit_count, const char *prefix, const char *field) +static char * +gdb_fread_strlist(void) { - char buff[32]; - unsigned char *c = dest; - short *sh = dest; - int *li = dest; - double *db = dest; + char *res = NULL; + int count; - if ((bit_count >> 3) != size) - fatal(MYNAME "%s: Internal error (gdb_le_read/%d/%d/%s)!\n", prefix, (int)size, bit_count >> 3, field); - - switch(bit_count) - { - case 8: - gdb_fread(c, sizeof(*c)); - if (gdb_debug) - printf(MYNAME "%s: gdb_fread_le : %d -> %s (0x%x))\n", prefix, *c, field, *c); - return *c; - case 16: - if (sizeof(*sh) != size) fatal(MYNAME ": internal decl.!\n"); - gdb_fread(sh, sizeof(*sh)); - *sh = le_read16(sh); - if (gdb_debug) - printf(MYNAME "%s: gdb_fread_le : %d -> %s (0x%x))\n", prefix, *sh, field, *sh); - return *sh; - case 32: - gdb_fread(li, 4); - *li = le_read32(li); - if (gdb_debug) - printf(MYNAME "%s: gdb_fread_le : %d -> %s (0x%x)\n", prefix, *li, field, *li); - return *li; - case 64: - gdb_fread(buff, sizeof(*db)); - le_read64(db, buff); - if (gdb_debug) - printf(MYNAME "%s: gdb_fread_le : %g -> %s\n", prefix, *db, field); - return 0; - default: - fatal(MYNAME "%s: unsupported bit count (%d) in gdb_le_read!\n", prefix, bit_count); + count = FREAD_i32; + + while (count > 0) { + char *str = FREAD_CSTR; + if (str != NULL) { + if (*str && (res == NULL)) res = str; + else xfree(str); + } + count--; + } + + return res; +} + +static waypoint * +gdb_find_wayptq(const queue *Q, const waypoint *wpt, const char exact) +{ + queue *elem, *tmp; + const char *name = wpt->shortname; + + QUEUE_FOR_EACH(Q, elem, tmp) { + waypoint *tmp = (waypoint *)elem; + if (case_ignore_strcmp(name, tmp->shortname) == 0) { + + if (! exact) return tmp; + + if ((tmp->latitude == wpt->latitude) && + (tmp->longitude == wpt->longitude)) + return tmp; + } } - return 0; + return NULL; } -static int -gdb_fread_flag(const char value) /* read one byte and compare to value */ +static waypoint * +gdb_reader_find_waypt(const waypoint *wpt, const char exact) { - char c; + waypoint *res; + res = gdb_find_wayptq(&wayptq_in, wpt, exact); + if (res == NULL) + res = gdb_find_wayptq(&wayptq_in_hidden, wpt, exact); + return res; +} + +static waypoint * +gdb_add_route_waypt(route_head *rte, waypoint *ref, const int wpt_class) +{ + waypoint *tmp, *res; + int turn_point; + + tmp = gdb_reader_find_waypt(ref, 1); + if (tmp == NULL) { + double dist; + + tmp = find_waypt_by_name(ref->shortname); + if (tmp == NULL) { + route_add_wpt(rte, ref); + return ref; + } + + /* At this point we have found a waypoint with same name, + but probably from another data stream. Check coordinates! + */ + dist = radtometers(gcdist( + RAD(ref->latitude), RAD(ref->longitude), + RAD(tmp->latitude), RAD(tmp->longitude))); + + if (fabs(dist) > 100) { + warning(MYNAME ": Route point mismatch!\n"); + warning(MYNAME ": \"%s\" from waypoints differs to \"%s\"\n", + tmp->shortname, ref->shortname); + fatal(MYNAME ": from route table by more than %0.1f meters!\n", + dist); + + } + } + res = NULL; + turn_point = (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && tmp->description); + if (turn_point || (gdb_via == 0) || (wpt_class < gt_waypt_class_map_point)) { + res = waypt_dupe(tmp); + route_add_wpt(rte, res); + } + waypt_free(ref); + return res; +} + +/*******************************************************************************/ +/* TOOLS AND MACROS FOR THE WRITER */ +/*-----------------------------------------------------------------------------*/ - gdb_fread(&c, 1); - return (c == value); +#define FWRITE_CSTR(a) ((a) == NULL) ? gbfputc(0,fout) : gbfputcstr((a),fout) +#define FWRITE_i16(a) gbfputint16((a),fout) +#define FWRITE_i32(a) gbfputint32((a),fout) +#define FWRITE(a, b) gbfwrite(a,(b),1,fout) +#define FWRITE_C(a) gbfputc((a),fout) +#define FWRITE_DBL(a,b) gdb_write_dbl((a),(b)) +#define FWRITE_TIME(a) gdb_write_time((a)) +#define FWRITE_CSTR_LIST(a) gdb_write_cstr_list((a)) +#define FWRITE_LATLON(a) gbfputint32(GPS_Math_Deg_To_Semi((a)),fout) + +static void +gdb_write_cstr_list(const char *str) +{ + if NOT_EMPTY(str) { + gbfputint32(1, fout); + gbfputcstr(str, fout); + } else + gbfputint32(0, fout); } static void -gdb_is_valid(int is, const char *prefix, const char *comment) +gdb_write_dbl(const double value, const double def) { - if (is == 0) - { - printf(MYNAME ": Reading database \"%s\"\n", fin_name); - fatal(MYNAME "-%s: Found error in data (%s)!\n", prefix, comment); + if (value == def) gbfputc(0, fout); + else { + gbfputc(1, fout); + gbfputdbl(value, fout); } } static void -gdb_is_validf(int is, const char *prefix, const char *format, ...) +gdb_write_time(const int time) { - va_list args; - - if (is != 0) return; - - va_start(args, format); - if (fin_name != NULL) - printf(MYNAME "-%s: Reading from database \"%s\"\n", prefix, fin_name); + if (time > 0) { + gbfputc(1, fout); + gbfputint32(time, fout); + } else - printf(MYNAME "-%s: Writing to database \"%s\"\n", prefix, fout_name); - printf(MYNAME "-%s: ", prefix); - vprintf(format, args); - va_end(args); - - fatal("\n"); + gbfputc(0, fout); } -/********************************************************************************************************/ -/* %%% read file header */ -/********************************************************************************************************/ +/*******************************************************************************/ +/* GDB "Garmin Database" READER CODE */ +/*-----------------------------------------------------------------------------*/ static void -gdb_read_file_header(void) +read_file_header(void) { - char buff[128]; + char buf[128]; int i, reclen; - - const char *prefix = "read_head"; + /* - We starts with standard binary read. - A gdb_fread_str works too, but if we get a wrong file as input, + We are beginning with a simple binary read. +*/ + FREAD(buf, 6); +/* + A "gbfgetcstr" (FREAD_CSTR) works too, but if we get a wrong file as input, the file validation my be comes too late. For example a XML base file normally has no binary zeros inside and produce, if big enought, a buffer overflow. The following message "local buffer overflow detected..." could be misinterpreted. */ - - if (6 != fread(buff, 1, 6, fin)) - fatal(MYNAME ": Invalid file \"%s\"!\n", fin_name); + is_fatal(strcmp(buf, "MsRcf") != 0, MYNAME ": Invalid file \"%s\"!", fin->name); - if (strcmp(buff, "MsRcf") != 0) - fatal(MYNAME ": Invalid file \"%s\"!\n", fin_name); - - gdb_fread(&reclen, 4); - reclen = le_read32(&reclen); - - gdb_is_valid(reclen == gdb_fread_str(buff, sizeof(buff)), prefix, "Invalid record length"); - if (buff[0] != 'D') - fatal(MYNAME ": Invalid file \"%s\"!\n", fin_name); + reclen = FREAD_i32; + i = FREAD_STR(buf); + is_fatal(buf[0] != 'D', MYNAME ": Invalid file \"%s\"!", fin->name); - switch(buff[1]) - { - case 'k': - gdb_ver = 1; - break; - case 'l': - gdb_ver = 2; - break; - case 'm': - gdb_ver = 3; - break; - default: - fatal(MYNAME ": Non supported GDB version!\n"); - } + gdb_ver = buf[1] - 'k' + 1; + is_fatal((gdb_ver < GDB_VER_MIN) || (gdb_ver > GDB_VER_MAX), + MYNAME ": Unknown or/and unsupported GDB version (%d.0)!", gdb_ver); if (global_opts.verbose_status > 0) - printf(MYNAME ": Found Garmin GPS Database version %d.0\n", gdb_ver); - - gdb_fread(&reclen, 4); - reclen = le_read32(&reclen); - gdb_is_valid(reclen < (int)sizeof(buff), prefix, "Invalid record length"); - gdb_fread(buff, reclen); - - gdb_is_valid(0 == gdb_fread_str(buff, sizeof(buff)), prefix, "header"); - - i = gdb_fread_str(buff, sizeof(buff)); - gdb_is_valid((i == 9) && (strcmp(buff, "MapSource") == 0), prefix, "MapSource magic"); + printf(MYNAME ": Reading Garmin GPS Database version %d.0\n", gdb_ver); + + reclen = FREAD_i32; + i = FREAD(buf, reclen + 1); + if (global_opts.verbose_status > 0) { + char *name = buf+2; + if (strstr(name, "SQA") == 0) name = "MapSource"; + else if (strstr(name, "neaderhi") == 0) name = "MapSource BETA"; + warning(MYNAME ": File created with \"%s\"\n", name); + } + + i = FREAD_STR(buf); + is_fatal((i != 9) || (strcmp(buf, "MapSource") != 0), "Invalid header!"); } -/********************************************************************************************************/ -/* %%% read waypoint */ -/********************************************************************************************************/ +/*-----------------------------------------------------------------------------*/ static waypoint * -gdb_read_wpt(const size_t fileofs, int *wptclass) +read_waypoint(gt_waypt_classes_e *waypt_class_out) { - char xname[GDB_NAME_BUFFERLEN]; - char xnotes[GDB_NOTES_BUFFERLEN]; - char xurl[GDB_URL_BUFFERLEN]; - int xclass; - int xlat, xlon, xdisplay, xcolour, xicon, xtime, dynamic; - short xcat; - double xdepth = unknown_alt; - double xalt = unknown_alt; - double xproximity = unknown_alt; - double xtemp; + char buf[128]; /* used for temporary stuff */ + int wpt_class, display, icon, dynamic; + int i; waypoint *res; - char buff[128]; - size_t pos, delta; - garmin_fs_t *gmsd = NULL; - - const char *prefix = "wpt_read"; - + garmin_fs_t *gmsd; + char *str; +#ifdef GMSD_EXPERIMENTAL + char subclass[22]; +#endif +#if GDB_DEBUG + char *sn; +#endif + waypt_ct++; res = waypt_new(); - + gmsd = garmin_fs_alloc(-1); fs_chain_add(&res->fs, (format_specific_data *) gmsd); - -/********************************************************************************************************/ -/* record structure - - zstring name - dword class - zstring country - 4 * 0x00 subclass part 1 - 12 * 0xFF subclass part 2 - 2 * 0x00 subclass part 3 - 4 * 0xFF unknown - dword latitude - dword longitude - if (1) +8 altitude = (1 or 9) - zstring comment - dword display flag - dword display colour - dword icon - zstring city ? - zstring state ? - zstring facility ? - char unknown ? - double depth (if flag) - zstring url - word category -> offset 79 - double temp (if flag) - */ -/********************************************************************************************************/ - - gdb_is_valid(gdb_fread_str(xname, sizeof(xname)) > 0, prefix, "new waypoint"); - res->shortname = xstrdup(xname); - - gdb_fread_le(&xclass, sizeof(xclass), 32, prefix, "class"); - GMSD_SET(wpt_class, xclass); - - gdb_fread_str(buff, sizeof(buff)); /* country code */ - GMSD_SETSTR(cc, buff); - - gdb_fread(buff, 22); - xlat = gdb_fread_le(&xlat, sizeof(xlat), 32, prefix, "latitude"); - xlon = gdb_fread_le(&xlon, sizeof(xlon), 32, prefix, "longitude"); - - if (gdb_fread_flag(1)) { /* altitude flag */ - gdb_fread_le(&xalt, sizeof(xalt), 64, prefix, "altitude"); - if (xalt > 1.0e24) - xalt = unknown_alt; + + res->shortname = FREAD_CSTR; +#if GDB_DEBUG + sn = xstrdup(nice(res->shortname)); +#endif + wpt_class = FREAD_i32; + GMSD_SET(wpt_class, wpt_class); + if (wpt_class != 0) waypth_ct++; + + FREAD_STR(buf); /* Country code */ + GMSD_SETSTR(cc, buf); + +#ifdef GMSD_EXPERIMENTAL + FREAD(subclass, sizeof(subclass)); + if (gmsd && (wpt_class >= gt_waypt_class_map_point)) { + memcpy(gmsd->subclass, subclass, sizeof(gmsd->subclass)); + gmsd->flags.subclass = 1; } - - gdb_fread_str(xnotes, sizeof(xnotes)); /* notes */ - - if (gdb_fread_flag(1)) { /* proximity flag */ - gdb_fread_le(&xproximity, sizeof(xproximity), 64, prefix, "proximity"); - GMSD_SET(proximity, xproximity); +#else + FREAD(buf, 22); +#endif + res->latitude = FREAD_LATLON; + res->longitude = FREAD_LATLON; + + if (FREAD_C == 1) { + double alt = FREAD_DBL; + if (alt < 1.0e24) { + res->altitude = alt; +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, 1) + printf(MYNAME "-wpt \"%s\" (%d): Altitude = %.1f\n", + sn, wpt_class, alt); +#endif + } } - - xdisplay = gdb_fread_le(&xdisplay, sizeof(xdisplay), 32, prefix, "display"); - switch(xdisplay) { - case gt_gdb_display_mode_symbol: - xdisplay = gt_display_mode_symbol; - break; +#if GDB_DEBUG + DBG(GDB_DBG_WPT, 1) + printf(MYNAME "-wpt \"%s\": coordinates = %c%0.6f %c%0.6f\n", + sn, + res->latitude < 0 ? 'S' : 'N', res->latitude, + res->longitude < 0 ? 'W' : 'E', res->longitude); +#endif + res->notes = FREAD_CSTR; +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, res->notes) { + char *str = gstrsub(res->notes, "\r\n", ", "); + printf(MYNAME "-wpt \"%s\" (%d): notes = %s\n", + sn, wpt_class, nice(str)); + xfree(str); + } +#endif + if (FREAD_C == 1) { + WAYPT_SET(res, proximity, FREAD_DBL); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, 1) + printf(MYNAME "-wpt \"%s\" (%d): Proximity = %.1f\n", + sn, wpt_class, res->proximity / 1000); +#endif + } + i = FREAD_i32; +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, i) + printf(MYNAME "-wpt \"%s\" (%d): display = %d\n", + sn, wpt_class, i); +#endif + switch(i) { /* display value */ + case gt_gdb_display_mode_symbol: + display = gt_display_mode_symbol; break; case gt_gdb_display_mode_symbol_and_comment: - xdisplay = gt_display_mode_symbol_and_comment; - break; - default: /* gt_gdb_display_mode_symbol_and_name and others */ - xdisplay = gt_display_mode_symbol_and_name; - break; + display = gt_display_mode_symbol_and_comment; break; + default: + display = gt_display_mode_symbol_and_name; break; + } + GMSD_SET(display, display); + + FREAD_i32; /* color/colour !not implemented! */ + icon = FREAD_i32; + GMSD_SET(icon, icon); /* icon */ + FREAD_STR(buf); /* city */ + GMSD_SETSTR(city, buf); + FREAD_STR(buf); /* state */ + GMSD_SETSTR(state, buf); + FREAD_STR(buf); /* facility */ + GMSD_SETSTR(facility, buf); + + FREAD(buf, 1); + + if (FREAD_C == 1) { + WAYPT_SET(res, depth, FREAD_DBL); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, 1) + printf(MYNAME "-wpt \"%s\" (%d): Depth = %.1f\n", + sn, wpt_class, res->depth); +#endif } - GMSD_SET(display, xdisplay); - - xcolour = gdb_fread_le(&xcolour, sizeof(xcolour), 32, prefix, "colour"); - - xicon = gdb_fread_le(&xicon, sizeof(xicon), 32, prefix, "icon"); - GMSD_SET(icon, xicon); - gdb_fread_str(buff, sizeof(buff)); /* city */ - GMSD_SETSTR(city, buff); + /* VERSION DEPENDENT CODE */ - gdb_fread_str(buff, sizeof(buff)); /* state */ - GMSD_SETSTR(state, buff); - - gdb_fread_str(buff, sizeof(buff)); /* facility */ - GMSD_SETSTR(facility, buff); - - gdb_fread(buff, 1); /* unknown */ - - if (gdb_fread_flag(1)) { /* depth flag */ - gdb_fread_le(&xdepth, sizeof(xdepth), 64, prefix, "depth"); - GMSD_SET(depth, xdepth); + if (gdb_ver <= GDB_VER_2) { + char *temp; + + FREAD(buf, 2); /* ?????????????????????????????????? */ + waypt_flag = FREAD_C; + if (waypt_flag == 0) + FREAD(buf, 3); + else + FREAD(buf, 2); + + temp = FREAD_CSTR; /* undocumented & unused string */ +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, temp) + printf(MYNAME "-wpt \"%s\" (%d): Unknown string = %s\n", + sn, wpt_class, nice(temp)); +#endif + if (temp) xfree(temp); + + res->url = FREAD_CSTR; + if (wpt_class != 0) { + res->description = res->url; + res->url = NULL; + } } - - if (gdb_ver >= 3) { - int url_ct, unkn; - char *url = NULL; - - unkn = gdb_fread_le(&unkn, sizeof(unkn), 32, prefix, "unknown dword(x) since v3"); - gdb_fread(buff, 2); - - gdb_fread_str(xurl, sizeof(xurl)); /* what dagmar will say */ - - url_ct = gdb_fread_le(&url_ct, sizeof(url_ct), 32, prefix, "number of urls (since v3)"); - gdb_is_valid((url_ct >= 0), prefix, "Number of urls (since v3)"); - - while (url_ct > 0) { - url_ct--; - gdb_fread_str(xurl, sizeof(xurl)); /* URL list */ - if ((url == NULL) && (xurl[0] != '\0')) - url = xstrdup(xurl); /* keep only the first valid entry */ - } - if (url != NULL) { - strncpy(xurl, url, sizeof(xurl)); - xfree(url); - } + else { // if (gdb_ver >= GDB_VER_3) + int i, url_ct; + + waypt_flag = 0; + + FREAD_STR(buf); /* street address */ + GMSD_SETSTR(addr, buf); + + FREAD(buf, 5); /* instruction depended */ + res->description = FREAD_CSTR; /* instruction */ + + url_ct = FREAD_i32; + for (i = url_ct; (i); i--) { + char *str = FREAD_CSTR; + if (str && *str) { + waypt_add_url(res, str, NULL); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, 1) + printf(MYNAME "-wpt \"%s\" (%d): url(%d) = %s\n", + sn, wpt_class, url_ct - i, str); +#endif + } + } } - else { /* gdb_ver <= 2 */ - gdb_fread(buff, 2); - if (gdb_fread_flag(0)) - gdb_fread(buff, 3); - else - gdb_fread(buff, 2); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, res->description) + printf(MYNAME "-wpt \"%s\" (%d): description = %s\n", + sn, wpt_class, nice(res->description)); + DBG(GDB_DBG_WPTe, res->url) + printf(MYNAME "-wpt \"%s\" (%d): url = %s\n", + sn, wpt_class, nice(res->url)); +#endif + i = FREAD_i16; + if (i != 0) GMSD_SET(category, i); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, i) + printf(MYNAME "-wpt \"%s\" (%d): category = %d\n", + sn, wpt_class, i); +#endif - do /* undocumented & unused string */ - { - gdb_fread(buff, 1); - } - while (buff[0] != 0); + if (FREAD_C == 1) { + WAYPT_SET(res, temperature, FREAD_DBL); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, 1) + printf(MYNAME "-wpt \"%s\" (%d): temperature = %.1f\n", + sn, wpt_class, res->temperature); +#endif + } - gdb_fread_str(xurl, sizeof(xurl)); /* URL */ + /* VERSION DEPENDENT CODE */ + if (gdb_ver <= GDB_VER_2) { + if (waypt_flag != 0) FREAD(buf, 1); } - - xcat = gdb_fread_le(&xcat, sizeof(xcat), 16, prefix, "category"); - if (xcat != 0) GMSD_SET(category, xcat); - - if (gdb_fread_flag(1)) { /* temperature flag */ - gdb_fread_le(&xtemp, sizeof(xtemp), 64, prefix, "temperature"); - GMSD_SET(temperature, xtemp); + if (FREAD_C == 1) { + res->creation_time = FREAD_i32; } - pos = ftell(fin); - delta = fileofs - pos; - gdb_is_valid((delta > 0), prefix, "waypoint final"); - - if (gdb_ver >= 3) { - delta--; - if (gdb_fread_flag(1)) { - gdb_is_valid((delta >= 4), prefix, "No waypoint time (v3++)"); - gdb_fread_le(&xtime, sizeof(xtime), 32, prefix, "time"); - gdb_is_valid((xtime > 0), prefix, "Invalid time (v3++)"); - delta-=sizeof(xtime); - } - else - xtime = 0; - if (delta > 0) { /* skip over trailing unknown bytes */ - gdb_is_valid((delta <= sizeof(buff)), prefix, "Waypoint structure V3"); - gdb_fread(buff, delta); - } - } - else { /* gdb_ver <= 2 */ - - /* Here comes 1 .. 6 unknown bytes - !!! 6 only if class > 0 !!! - the field seems to be a time stamp */ - - if ((delta & 1) == 0) { - delta--; - gdb_fread(buff, 1); - if (buff[0] != '\0') - warning(MYNAME ": Invalid byte (0x%02x) at EOW'.\n", (unsigned char)buff[0]); - } - - xtime = 0; - - delta--; - if (gdb_fread_flag(1)) { - gdb_is_valid((delta == 4), prefix, "Waypoint time"); - gdb_fread_le(&xtime, sizeof(xtime), 32, prefix, "time"); - } - else if (delta > 0) { - gdb_is_valid((delta <= sizeof(buff)), prefix, "Waypoint structure"); - gdb_fread(buff, delta); - if (xclass < gt_waypt_class_map_point) { - warning(MYNAME ": Unhandled EOW. Please report!\n"); - fatal(MYNAME ": [class is 0x%02xh, %d bytes left, gdb version %d]\n", - xclass, (int)delta, gdb_ver); + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_3) { + if (FREAD_i32 == 1) { + FREAD_STR(buf); /* phone number */ + GMSD_SETSTR(phone_nr, buf); + FREAD_STR(buf); /* ?? fax / mobile ?? */ } - } + FREAD_STR(buf); /* country */ + GMSD_SETSTR(country, buf); + FREAD_STR(buf); /* postal code */ + GMSD_SETSTR(postal_code, buf); } - *wptclass = xclass; - - if (xurl[0] != '\0') - { - if (xclass == 0) - res->url = xstrdup(xurl); - else - res->description = xstrdup(xurl); - } - if (xnotes[0] != '\0') res->notes = xstrdup(xnotes); - res->latitude = GPS_Math_Semi_To_Deg(xlat); - res->longitude = GPS_Math_Semi_To_Deg(xlon); - res->altitude = xalt; - res->creation_time = xtime; - - /* might need to change this to handle version dependent icon handling */ - res->icon_descr = gt_find_desc_from_icon_number(xicon, GDB, &dynamic); + res->icon_descr = gt_find_desc_from_icon_number(icon, GDB, &dynamic); res->wpt_flags.icon_descr_is_dynamic = dynamic; - gdb_is_validf(fabs(res->latitude) <= 90.0, prefix, "%s has invalid latitude (%f)", - res->shortname, res->latitude); +#if GDB_DEBUG + DBG(GDB_DBG_WPTe, icon != GDB_DEF_ICON) + printf(MYNAME "-wpt \"%s\" (%d): icon = \"%s\" (MapSource symbol %d)\n", + sn, wpt_class, nice(res->icon_descr), icon); +#endif + if ((str = GMSD_GET(cc, NULL))) { + if (! GMSD_HAS(country)) + GMSD_SETSTR(country, gt_get_icao_country(str)); + } + if (gdb_roadbook && (wpt_class > gt_waypt_class_map_point) && res->description) { + wpt_class = gt_waypt_class_user_waypoint; + GMSD_SET(wpt_class, wpt_class); +#ifdef GMSD_EXPERIMENTAL + GMSD_UNSET(subclass); +#endif + } +#if GDB_DEBUG + xfree(sn); +#endif + *waypt_class_out = wpt_class; return res; } -/********************************************************************************************************/ -/* %%% read route */ -/********************************************************************************************************/ +/*-----------------------------------------------------------------------------*/ static route_head * -gdb_read_route(void) +read_route(void) { - char xname[GDB_NAME_BUFFERLEN]; - char xwptname[GDB_NAME_BUFFERLEN]; - int xclass; - double xalt; - double xlat = 0; /* compiler warnings */ - double xlon = 0; /* compiler warnings */ - - char buff[256]; - int count, origin; - int isteps; - int semilat, semilon; - int maxlat, maxlon, minlon, minlat; - char auto_name; - - route_head *route; - waypoint *wpt; - - const char prefix[] = "rte_read_head"; - const char prefix1[] = "rte_read_loop"; - const char prefix2[] = "rte_ils_loop"; - const char prefix3[] = "rte_read_final"; + route_head *rte; + int points, warnings, links, i; + char buf[128]; + bounds bounds; - gdb_is_valid(gdb_fread_str(xname, sizeof(xname)) > 0, prefix, "Route has no name"); - - gdb_fread_le(&auto_name, sizeof(auto_name), 8, prefix, "auto name"); - if (gdb_fread_flag(0)) /* max. data flag */ - { - gdb_fread_le(buff, 4, 32, prefix, "max. latitude"); - gdb_fread_le(buff, 4, 32, prefix, "max. longitude"); - - gdb_fread(buff, 1); - if (buff[0] == 1) gdb_fread_le(buff, 8, 64, prefix, "max. altitude"); - - gdb_fread_le(buff, 4, 32, prefix, "min. latitude"); - gdb_fread_le(buff, 4, 32, prefix, "min. longitude"); + rte_ct++; + warnings = 0; - gdb_fread(buff, 1); - if (buff[0] == 1) - gdb_fread_le(buff, 8, 64, prefix, "min. altitude"); + rte = route_head_alloc(); + rte->rte_name = FREAD_CSTR; + FREAD(buf, 1); /* display/autoname - 1 byte */ + + if (FREAD_C == 0) { /* max. data flag */ + /* maxlat = */ (void) FREAD_i32; + /* maxlon = */ (void) FREAD_i32; + if (FREAD_C == 1) /* maxalt = */ FREAD_DBL; + /* minlat = */ (void) FREAD_i32; + /* minlon = */ (void) FREAD_i32; + if (FREAD_C == 1) /* minalt = */ FREAD_DBL; } - - gdb_fread_le(&count, sizeof(count), 32, prefix, "count"); - - if (count == 0) - fatal(MYNAME "%s: !!! Empty routes are not allowed !!!\n", prefix); - - route = route_head_alloc(); - route->rte_name = xstrdup(xname); - route_add_head(route); - - origin = count; - while (count--) - { - garmin_fs_t *gmsd = NULL; - garmin_ilink_t *anchor; - - gdb_fread_str(xwptname, sizeof(xwptname)); /* waypoint name */ + links = 0; + points = FREAD_i32; - gdb_fread_le(&xclass, sizeof(xclass), 32, prefix1, "class"); /* class */ - gdb_fread_str(buff, sizeof(buff)); /* country */ - - gdb_fread(buff, 22); /* sub class data */ - gdb_fread(buff, 1); - if (buff[0] != 0) { /* 0x00 or 0xFF */ - gdb_fread(buff, 8); /* unknown 8 bytes */ -#ifdef GDB_DEBUG - gdb_print_buff(buff, 8, "Unknown bytes within rte_reed_loop"); +#if GDB_DEBUG + DBG(GDB_DBG_RTE, 1) + printf(MYNAME "-rte \"%s\": loading route with %d point(s)...\n", + nice(rte->rte_name), points); #endif - if (gdb_ver >= 3) - gdb_fread(buff, 8); /* a second block of unknown bytes */ - } - /* The next thing is the unknown 0x03 0x00 .. 0x00 (18 bytes) */ - /* OK: this should be, but i've seen exceptions (...cannot verify the first byte */ - gdb_fread(buff, 18); + for (i = 0; i < points; i++) { + int wpt_class, j; + char buf[128]; + garmin_ilink_t *il_root, *il_anchor; - gdb_fread_le(&isteps, sizeof(isteps), 32, prefix1, "interlink steps"); - - if (isteps <= 0) /* ??? end of route or error ??? */ - { - gdb_is_valid(count == 0, prefix3, "Zero interlink steps within route"); - - gdb_fread(buff, 1); - gdb_is_valid((buff[0] == 1), prefix3, "last seq.(1)"); + waypoint *wpt; - if (gdb_ver >= 2) - gdb_fread(buff, 8); /* Unknown 8 bytes since gdb v2 */ + wpt = waypt_new(); + rtept_ct++; + + wpt->shortname = FREAD_CSTR; /* shortname */ + wpt_class = FREAD_i32; /* waypoint class */ + FREAD_STR(buf); /* country code */ + FREAD(buf, 18 + 4); /* subclass part 1-3 / unknown */ + + if (FREAD_C != 0) { + FREAD(buf, 8); /* aviation data (?); only seen with class "1" (Airport) */ + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_3) + FREAD(buf, 8); /* a second block since V3 */ + } - gdb_fread_str(xname, sizeof(xname)); - if (xname[0] != 0) - route->rte_url = xstrdup(xname); + FREAD(buf, 18); /* unknown 18 bytes; but first should be 0x01 or 0x03 */ + if ((buf[0] != 0x01) && (buf[0] != 0x03)) { + int i; + + warnings++; + if (warnings > 3) + fatal(MYNAME "-rte_pt \"%s\": too many warnings!\n", wpt->shortname); + warning(MYNAME "-rte_pt \"%s\" (class %d): possible error in route.\n", wpt->shortname, wpt_class); + warning(MYNAME "-rte_pt (dump):"); + for (i = 0; i < 18; i++) { + warning(" %02x", (unsigned char)buf[i]); + } + warning("\n"); + } - if (gdb_ver >= 3) { - - int url_ct, unkn; - - gdb_fread(buff, 1); /* Unknown byte since gdb v3 */ - gdb_fread_le(&url_ct, sizeof(url_ct), 32, prefix3, "number of urls (since v3)"); - while (url_ct > 0) { - url_ct--; - gdb_fread_str(xname, sizeof(xname)); - if (route->rte_url == NULL) - route->rte_url = xstrdup(xname); - } - gdb_fread_le(&unkn, sizeof(unkn), 32, prefix3, "unknown dword (since v3)"); - gdb_fread(buff, 1); /* Unknown byte since gdb v3 */ - gdb_fread_str(xname, sizeof(xname)); /* multi-line notes */ - if (xname[0] != '\0') - route->rte_desc = xstrdup(xname); + links = FREAD_i32; + il_anchor = NULL; + il_root = NULL; +#if GDB_DEBUG + DBG(GDB_DBG_RTE, links) + printf(MYNAME "-rte_pt \"%s\" (%d): %d interlink step(s)\n", + nice(wpt->shortname), wpt_class, links); +#endif + for (j = 0; j < links; j++) { + garmin_ilink_t *il_step = xmalloc(sizeof(*il_step)); + + il_step->ref_count = 1; + + il_step->lat = FREAD_LATLON; + il_step->lon = FREAD_LATLON; + if (FREAD_C == 1) il_step->alt = FREAD_DBL; + else il_step->alt = unknown_alt; + + if (j == 0) { + wpt->latitude = il_step->lat; + wpt->longitude = il_step->lon; + wpt->altitude = il_step->alt; + } + + il_step->next = NULL; + if (il_anchor == NULL) + il_root = il_step; + else + il_anchor->next = il_step; + il_anchor = il_step; + +#if GDB_DEBUG + DBG(GDB_DBG_RTEe, 1) { + printf(MYNAME "-rte_il \"%s\" (%d of %d): %c%0.6f %c%0.6f\n", + nice(wpt->shortname), j + 1, links, + il_step->lat < 0 ? 'S' : 'N', il_step->lat, + il_step->lon < 0 ? 'W' : 'E', il_step->lon); + } +#endif } - wpt = gdb_create_rte_wpt(xwptname, xlat, xlon, xalt); - if (wpt != NULL) - route_add_wpt(route, wpt); - return route; - } - - gdb_fread_le(&semilat, sizeof(semilat), 32, prefix1, "semi-latitude"); - gdb_fread_le(&semilon, sizeof(semilon), 32, prefix1, "semi-longitude"); - xlat = GPS_Math_Semi_To_Deg(semilat); - xlon = GPS_Math_Semi_To_Deg(semilon); - - gdb_is_validf(fabs(xlat) <= 90.0, prefix1, "Invalid latitude (%f)", xlat); - - if (gdb_fread_flag(1)) /* altitude flag */ - gdb_fread_le(&xalt, sizeof(xalt), 64, prefix1, "altitude"); - else - xalt = unknown_alt; - - wpt = gdb_create_rte_wpt(xwptname, xlat, xlon, xalt); - if (wpt != NULL) { - route_add_wpt(route, wpt); - gmsd = GMSD_FIND(wpt); - if (gmsd == NULL) { - gmsd = garmin_fs_alloc(-1); - fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); + + waypt_init_bounds(&bounds); + + if (FREAD_C == 0) { /* interlink bounds */ + bounds.max_lat = FREAD_LATLON; + bounds.max_lon = FREAD_LATLON; + if (FREAD_C == 1) + bounds.max_alt = FREAD_DBL; + bounds.min_lat = FREAD_LATLON; + bounds.min_lat = FREAD_LATLON; + if (FREAD_C == 1) + bounds.min_alt = FREAD_DBL; } - GMSD_SET(wpt_class, xclass); - } - else { - gmsd = NULL; - } - - anchor = NULL; - - while (--isteps > 0) - { - gdb_fread_le(&semilat, sizeof(semilat), 32, prefix2, "semi-latitude"); - gdb_fread_le(&semilon, sizeof(semilon), 32, prefix2, "semi-longitude"); - gdb_fread(buff, 1); /* altitude flag */ - if (buff[0] == 1) - gdb_fread_le(&xalt, sizeof(xalt), 64, prefix2, "altitude"); - - xlat = GPS_Math_Semi_To_Deg(semilat); - xlon = GPS_Math_Semi_To_Deg(semilon); - gdb_is_validf(fabs(xlat) <= 90.0, prefix2, "Invalid latitude (%f)", xlat); - if (gmsd != NULL) - { - garmin_ilink_t *ilink_ptr = xmalloc(sizeof(*ilink_ptr)); - - ilink_ptr->ref_count = 1; - ilink_ptr->lat = xlat; - ilink_ptr->lon = xlon; - ilink_ptr->next = NULL; - - if (anchor == NULL) { - gmsd->ilinks = ilink_ptr; - } else { - anchor->next = ilink_ptr; - } - anchor = ilink_ptr; + if (links == 0) { + /* Without links we need all informations from wpt */ + waypoint *tmp = gdb_reader_find_waypt(wpt, 0); + if (tmp != NULL) { + waypt_free(wpt); + wpt = waypt_dupe(tmp); + } + else { + if (waypt_bounds_valid(&bounds)) + warning(MYNAME ": (has bounds)\n"); + + warning(MYNAME ": Data corruption detected!\n"); + fatal(MYNAME ": Sleeping route point without coordinates!\n"); + } } - } - - gdb_fread(buff, 1); - gdb_is_valid(buff[0] == 0, prefix1, "\"Zero\" byte expected"); - - gdb_fread_le(&maxlat, sizeof(maxlat), 32, prefix1, "max. latitude"); - gdb_fread_le(&maxlon, sizeof(maxlon), 32, prefix1, "max. longitude"); - - if (gdb_fread_flag(1)) /* link max alt validity + alt */ - gdb_fread(buff, 8); - gdb_fread_le(&minlat, sizeof(minlat), 32, prefix1, "min. latitude"); - gdb_fread_le(&minlon, sizeof(minlon), 32, prefix1, "min. longitude"); - - if (gdb_fread_flag(1)) /* link min alt validity + alt */ - gdb_fread(buff, 2 * sizeof(int)); + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_2) { + FREAD(buf, 8); + if (gdb_ver >= GDB_VER_3) { + FREAD(buf, 2); + } + } +#if GDB_DEBUG + DBG(GDB_DBG_RTE, 1) + printf(MYNAME "-rte_pt \"%s\": coordinates = %c%0.6f, %c%0.6f\n", + nice(wpt->shortname), + wpt->latitude < 0 ? 'S' : 'N', wpt->latitude, + wpt->longitude < 0 ? 'W' : 'E', wpt->longitude); +#endif + wpt = gdb_add_route_waypt(rte, wpt, wpt_class); + if (wpt != NULL) { + garmin_fs_t *gmsd = GMSD_FIND(wpt); + if (gmsd == NULL) { + gmsd = garmin_fs_alloc(-1); + fs_chain_add(&wpt->fs, (format_specific_data *) gmsd); + } + GMSD_SET(wpt_class, wpt_class); + gmsd->ilinks = il_root; + il_root = NULL; + } - if (gdb_ver >= 2) - gdb_fread(buff, 8); /* unknown 8 bytes since gdb v2 */ - if (gdb_ver >= 3) - gdb_fread(buff, 2); /* unknown 8 bytes since gdb v3 */ - } - - /* This should normally never happen; end of route is handled in main loop before this */ + while (il_root) { + garmin_ilink_t *il = il_root; + il_root = il_root->next; + xfree(il); + } + } /* ENDFOR: for (i = 0; i < points; i++) */ - fatal(MYNAME "-%s: Unexpected end of route \"%s\"!", prefix1, xname); - return 0; + /* VERSION DEPENDENT CODE */ + if (gdb_ver <= GDB_VER_2) { + rte->rte_url = FREAD_CSTR; + } + else { + rte->rte_url = gdb_fread_strlist(); + + FREAD(buf, 4); /* ?????????????????????????????????? */ + FREAD(buf, 1); /* ?????????????????????????????????? */ + + rte->rte_desc = FREAD_CSTR; +#if 0 + /* replace CRLF's with ", " */ + if (rte->rte_desc) { + char *c = rte->rte_desc; + while ((c = strstr(c, "\r\n"))) { + *c++ = ','; + *c++ = ' '; + } + } +#endif + } + return rte; } +/*-----------------------------------------------------------------------------*/ static route_head * -gdb_read_track(const size_t max_file_pos) +read_track(void) { - char xname[GDB_NAME_BUFFERLEN]; - unsigned char xdisplay; - int xcolour; - int xlat; - int xlon; - int xtime = 0; - double xalt = unknown_alt; - double xdepth = unknown_alt; - double xtemp; - - char buff[128]; - int count; + route_head *res; + int points, index; + char dummy; - route_head *track; - waypoint *wpt; - - const char *prefix0 = "trk_read"; - const char *prefix = "trk_read_loop"; - - gdb_fread_str(xname, sizeof(xname)); - - gdb_fread_le(&xdisplay, sizeof(xdisplay), 8, prefix0, "display"); - gdb_fread_le(&xcolour, sizeof(xcolour), 32, prefix0, "colour"); - gdb_fread_le(&count, sizeof(count), 32, prefix0, "count"); + trk_ct++; + + res = route_head_alloc(); + res->rte_name = FREAD_CSTR; +// res->rte_num = trk_ct; - track = route_head_alloc(); - track->rte_name = xstrdup(xname); - track_add_head(track); + FREAD(&dummy, 1); /* display - 1 byte */ + FREAD_i32; /* color - 1 dword */ - while (count--) + points = FREAD_i32; + + for (index = 0; index < points; index++) { - gdb_fread_le(&xlat, sizeof(xlat), 32, prefix, "latitude"); - gdb_fread_le(&xlon, sizeof(xlon), 32, prefix, "longitude"); - - gdb_fread(buff, 1); /* altitude flag */ - if (buff[0] == 1) - gdb_fread_le(&xalt, sizeof(xalt), 64, prefix, "altitude"); - - gdb_fread(buff, 1); /* date/time flag */ - if (buff[0] == 1) - gdb_fread_le(&xtime, sizeof(xtime), 32, prefix, "time"); - - gdb_fread(buff, 1); /* depth flag */ - if (buff[0] == 1) - gdb_fread_le(&xdepth, sizeof(xdepth), 64, prefix, "depth"); - - gdb_fread(buff, 1); /* temperature flag */ - if (buff[0] == 1) - gdb_fread_le(&xtemp, sizeof(xtemp), 64, prefix, "temperature"); - - wpt = waypt_new(); - - wpt->latitude = GPS_Math_Semi_To_Deg(xlat); - wpt->longitude = GPS_Math_Semi_To_Deg(xlon); - wpt->creation_time = xtime; - wpt->microseconds = 0; - wpt->altitude = xalt; - wpt->depth = xdepth; - - gdb_is_validf(fabs(wpt->latitude) <= 90.0, prefix, "Invalid latitude (%f)", wpt->latitude); - - track_add_wpt(track, wpt); + waypoint *wpt = waypt_new(); + + trkpt_ct++; + + wpt->latitude = FREAD_LATLON; + wpt->longitude = FREAD_LATLON; + if (FREAD_C == 1) { + double alt = FREAD_DBL; + if (alt < 1.0e24) wpt->altitude = alt; + } + if (FREAD_C == 1) { + wpt->creation_time = FREAD_i32; + } + if (FREAD_C == 1) { + WAYPT_SET(wpt, depth, FREAD_DBL); + } + if (FREAD_C == 1) { + WAYPT_SET(wpt, temperature, FREAD_DBL); + } + + track_add_wpt(res, wpt); } - if (gdb_ver >= 3) { - int url_ct; - - gdb_fread_le(&url_ct, sizeof(url_ct), 32, prefix, "number of urls (since v3)"); - while (url_ct > 0) { - url_ct--; - gdb_fread_str(xname, sizeof(xname)); - if ((track->rte_url == NULL) && (xname[0] != '\0')) - track->rte_url = xstrdup(xname); - } - } else { - gdb_fread_str(xname, sizeof(xname)); - if (xname[0] != '\0') - track->rte_url = xstrdup(xname); + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_3) { + res->rte_url = gdb_fread_strlist(); } - - return track; + else /* if (gdb_ver <= GDB_VER_2) */ { + res->rte_url = FREAD_CSTR; + } +#if GDB_DEBUG + DBG(GDB_DBG_TRK, res->rte_url) + printf(MYNAME "-trk \"%s\": url = %s\n", + res->rte_name, res->rte_url); +#endif + return res; } /*******************************************************************************/ static void -gdb_read_data(void) +init_reader(const char *fname) { - queue *elem, *temp; - int reclen, warnings; - char typ; - size_t curpos, anchor; - int wptclass; - - const char *prefix = "main_read_loop"; - - QUEUE_INIT(&gdb_hidden); + fin = gbfopen_le(fname, "rb", MYNAME); + read_file_header(); + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_UTF8) + cet_convert_init(CET_CHARSET_UTF8, 1); + + QUEUE_INIT(&wayptq_in); + QUEUE_INIT(&wayptq_in_hidden); + + gdb_via = (gdb_opt_via && *gdb_opt_via) ? atoi(gdb_opt_via) : 0; + gdb_roadbook = (gdb_opt_roadbook && *gdb_opt_roadbook) ? atoi(gdb_opt_roadbook) : 0; + if (gdb_roadbook) /* higher priority */ gdb_via = 1; + + waypt_ct = 0; + waypth_ct = 0; + rtept_ct = 0; + trkpt_ct = 0; + rte_ct = 0; + trk_ct = 0; +} - warnings = 0; - - anchor = ftell(fin); +static void +done_reader(void) +{ + disp_summary(fin); + gdb_flush_waypt_queue(&wayptq_in); + gdb_flush_waypt_queue(&wayptq_in_hidden); + gbfclose(fin); +} - /* we go twice through the file to keep sure, all waypoints - are loaded before any route has to be handled */ - - while (feof(fin) == 0) - { - - gdb_fread_le(&reclen, sizeof(reclen), 32, prefix, "record length"); - gdb_is_valid(reclen > 0 && reclen < 0x1F00000, prefix, "record length"); - gdb_fread(&typ, 1); - - curpos = ftell(fin); - - if (typ == 'W') - { - int delta; +static void +read_data(void) +{ + int incomplete = 0; /* number of incomplete reads */ + + for (;;) { + int len, delta; + char typ, dump; + gt_waypt_classes_e wpt_class; + gbsize_t pos; waypoint *wpt; + route_head *trk, *rte; - wpt = gdb_read_wpt(curpos + reclen, &wptclass); - if (wpt != NULL ) - { - if (wptclass == 0) { - waypt_add(wpt); - } - else if (gdb_via == 0) - ENQUEUE_TAIL(&gdb_hidden, &wpt->Q); - else - waypt_free(wpt); - } - delta = (int)((curpos + reclen) - ftell(fin)); - if (delta != 0) - { - if ((warnings & 1) == 0) - { - warnings |= 1; - warning(MYNAME "-%s: At least one incomplete waypoint (gdb v%d, %d byte(s) left).\n", prefix, gdb_ver, delta); - } - fseek(fin, curpos + reclen, SEEK_SET); - } - continue; - } - else if (typ == 'V') - break; + len = FREAD_i32; + FREAD(&typ, 1); + pos = gbftell(fin); - fseek(fin, curpos + reclen, SEEK_SET); - } - - clearerr(fin); - fseek(fin, anchor, SEEK_SET); - - - while (feof(fin) == 0) - { - gdb_fread_le(&reclen, sizeof(reclen), 32, prefix, "record length"); - gdb_is_valid(reclen > 0 && reclen < 0x1F00000, prefix, "record length"); - gdb_fread(&typ, 1); - - curpos = ftell(fin); - - if ((typ == 'R') || (typ == 'T')) - { - int flag, delta; + if (typ == 'V') break; /* break the loop */ - if (typ == 'R') - { - gdb_read_route(); - flag = 2; - } - else - { - gdb_read_track(curpos + reclen); - flag = 4; - } - delta = (int)((curpos + reclen) - ftell(fin)); - if (delta != 0) - { - if ((delta != reclen) && ((warnings & flag) == 0)) - { - warnings |= flag; - warning(MYNAME "-%s: At least one incomplete %s (gdb v%d, %d byte(s) left).\n", - prefix, (typ == 'R') ? "route" : "track", gdb_ver, delta); - } - fseek(fin, curpos + reclen, SEEK_SET); + dump = 1; + wpt_class = GDB_DEF_CLASS; + + switch(typ) { + case 'W': + wpt = read_waypoint(&wpt_class); + if ((gdb_via == 0) || (wpt_class == 0)) { + waypoint *dupe; + waypt_add(wpt); + dupe = waypt_dupe(wpt); + ENQUEUE_TAIL(&wayptq_in, &dupe->Q); + } + else + ENQUEUE_TAIL(&wayptq_in_hidden, &wpt->Q); + break; + case 'R': + rte = read_route(); + if (rte) route_add_head(rte); + break; + case 'T': + trk = read_track(); + if (trk) track_add_head(trk); + break; + default: + dump = 0; /* make a dump only for main types */ + break; } - } - else - { - if (typ == 'V') break; - switch(typ) - { - case 'D': break; - case 'L': break; - case 'W': break; - default: warning(MYNAME "-%s: Found unknown record type \"%c\" (gdb v%d)!\n", prefix, typ, gdb_ver); + delta = (pos + len) - gbftell(fin); + if (dump && delta) { + if (! incomplete++) { + warning(MYNAME ":==========================================\n"); + warning(MYNAME ":=== W A R N I N G ===\n"); + } + if (typ == 'W') + warning(MYNAME ":(%d%c-%02d): delta = %d (flag=%3d/%02x)-", + gdb_ver, typ, wpt_class, delta, waypt_flag, waypt_flag); + else + warning(MYNAME ":(%d%c): delta = %d -", gdb_ver, typ, delta); + if (delta > 0) { + int i; + char *buf = xmalloc(delta); + FREAD(buf, delta); + for (i = 0; i < delta; i++) { + warning(" %02x", (unsigned char)buf[i]); + } + xfree(buf); + } + warning("\n"); } - fseek(fin, curpos + reclen, SEEK_SET); - } - } - - QUEUE_FOR_EACH(&gdb_hidden, elem, temp) { /* finally kill our temporary queue */ - waypt_free((waypoint *) elem); - } -} - -/*******************************************************************************/ -/* %%% write support %%% */ -/*******************************************************************************/ - -/* helpers */ - -static waypoint ** -gdb_route_point_list(const route_head *route, int *count) -{ - waypoint **result; - queue *elem, *tmp; - int i = 0; - - QUEUE_FOR_EACH((queue *)&route->waypoint_list, elem, tmp) - { - waypoint *wpt = (waypoint *)elem; - if ((gdb_via == 0) || - (gdb_detect_rtept_class(wpt) == GDB_DEFAULTWPTCLASS)) i++; + gbfseek(fin, pos + len, SEEK_SET); } - *count = i; - if (i == 0) return NULL; - result = xcalloc(i, sizeof(*result)); - - i = 0; - QUEUE_FOR_EACH((queue *)&route->waypoint_list, elem, tmp) - { - waypoint *wpt = (waypoint *)elem; - if ((gdb_via == 0) || - (gdb_detect_rtept_class(wpt) == GDB_DEFAULTWPTCLASS)) - result[i++] = wpt; + if (incomplete) { + warning(MYNAME ":------------------------------------------\n"); + warning(MYNAME ": \"%s\"\n", fin->name); + warning(MYNAME ":------------------------------------------\n"); + warning(MYNAME ": Please mail this information\n"); + warning(MYNAME " and, if you can, the used GDB file\n"); + warning(MYNAME ": to gpsbabel-misc@lists.sourceforge.net\n"); + warning(MYNAME ":==========================================\n"); } - - return result; } -static void -gdb_fwrite(const void *data, const size_t size) -{ - fwrite(data, size, 1, fout); -} - -static void -gdb_fwrite_str(const char *str, const int len) -{ - - if (len >= 0) - gdb_fwrite(str, len); /* write a string with fixed length */ - else - { - char *tmp = (str != NULL) ? (char *)str : ""; - gdb_fwrite(tmp, strlen(tmp) + 1); - } -} - -static void -gdb_fwrite_le(const void *data, const size_t size) -{ - int i; - short s; - char buff[8]; - - switch(size) - { - case 1: - gdb_fwrite(data, 1); - break; - - case 2: /* sizeof(short): */ - s = *(short *)data; - le_write16(&s, s); - gdb_fwrite(&s, 2); - break; - - case 4: /* sizeof(int): */ - i = *(int *)data; - le_write32(&i, i); - gdb_fwrite(&i, 4); - break; - - case 8: /* sizeof(double): */ - le_read64(buff, data); - gdb_fwrite(buff, 8); - break; - - default: - fatal(MYNAME "-write_le: Unsupported data size (%lu)!\n", - (unsigned long) size); - } -} +/*******************************************************************************/ +/* + * reset_short_handle: used for waypoint, route and track names + */ static void -gdb_fwrite_alt(const double alt, const double unknown_value) -{ - char c0 = 0; - char c1 = 1; - - if (alt != unknown_value) /* proximity / depth / altitude */ - { - gdb_fwrite(&c1, 1); - gdb_fwrite_le(&alt, sizeof(alt)); - } - else - gdb_fwrite(&c0, 1); /* no value */ -} - -static void -gdb_fwrite_int(const int data) +reset_short_handle(const char *defname) { - gdb_fwrite_le(&data, sizeof(data)); -} - -static void -gdb_fwrite_icon(const waypoint *wpt) /* partly taken from mapsource.c */ -{ - int icon; - char buff[128]; - - if ( /* handle custom icons, which are linked to -2 in garmin_tables.c */ - (wpt->icon_descr != NULL) && - (sscanf(wpt->icon_descr, "%s%d", buff, &icon) == 2) && - (case_ignore_strcmp(buff, "Custom") == 0) && - (icon >= 0) && (icon <= 63) - ) - { - icon += 500; - } - else - { - /* might need to change this to handle version dependent icon handling */ - icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB); - if (get_cache_icon(wpt) /* && wpt->icon_descr && (strcmp(wpt->icon_descr, "Geocache Found") != 0)*/) - { - icon = gt_find_icon_number_from_desc(get_cache_icon(wpt), MAPSOURCE); - } - } - gdb_fwrite_le(&icon, sizeof(icon)); + if (short_h != NULL) + mkshort_del_handle(&short_h); + + short_h = mkshort_new_handle(); + + setshort_length(short_h, GDB_NAME_BUFFERLEN); + setshort_badchars(short_h, "\r\n\t"); + setshort_mustupper(short_h, 0); + setshort_mustuniq(short_h, 1); + setshort_whitespace_ok(short_h, 1); + setshort_repeating_whitespace_ok(short_h, 1); + setshort_defname(short_h, defname); } -/*******************************************************************************/ -/* %%% write file header %%% */ -/*-----------------------------------------------------------------------------*/ +/* ----------------------------------------------------------------------------*/ static void -gdb_write_file_header(void) +write_header(void) { char buff[128], tbuff[32]; char *c; int len; struct tm tm; - gdb_fwrite_str("MsRcf", -1); - gdb_fwrite_int(2); + FWRITE_CSTR("MsRcf"); + FWRITE_i32(2); strncpy(buff, "Dx", sizeof(buff)); buff[1] = 'k' - 1 + gdb_ver; - gdb_fwrite_str(buff, -1); + FWRITE_CSTR(buff); #if 0 /* Take this if anything is wrong with our self generated watermark */ - strncpy(buff, "A].SQA*Dec 27 2004*17:40:51", sizeof(buff)); /* MapSource V6.5 */ + strncpy(buff, "A].SQA*Dec 27 2004*17:40:51", sizeof(buff)); /* MapSource V6.5 */ #else /* This is our "Watermark" to show this file was created by GPSbabel */ /* history: - strncpy(buff, "A].GPSBabel_1.2.7-beta*Sep 13 2005*20:10:00", sizeof(buff)); // gpsbabel V1.2.7 BETA - strncpy(buff, "A].GPSBabel_1.2.8-beta*Jan 18 2006*20:11:00", sizeof(buff)); // gpsbabel 1.2.8-beta01182006_clyde - strncpy(buff, "A].GPSBabel_1.2.8-beta*Apr 18 2006*20:12:00", sizeof(buff)); // gpsbabel 1.2.8-beta20060405 - strncpy(buff, "A].GPSBabel-1.3*Jul 02 2006*20:13:00", sizeof(buff)); // gpsbabel 1.3.0 - strncpy(buff, "A].GPSBabel-1.3.1*Sep 03 2006*20:14:00", sizeof(buff)); // gpsbabel 1.3.1 - */ - - /* - New since 11/01/2006: - version: version and release of gpsbabel (defined in configure.in) - timestamp: date and time of gdb.c (handled by CVS) + + "A].GPSBabel_1.2.7-beta*Sep 13 2005*20:10:00" - gpsbabel V1.2.7 BETA + "A].GPSBabel_1.2.8-beta*Jan 18 2006*20:11:00" - gpsbabel 1.2.8-beta01182006_clyde + "A].GPSBabel_1.2.8-beta*Apr 18 2006*20:12:00" - gpsbabel 1.2.8-beta20060405 + "A].GPSBabel-1.3*Jul 02 2006*20:13:00" - gpsbabel 1.3.0 + "A].GPSBabel-1.3.1*Sep 03 2006*20:14:00" - gpsbabel 1.3.1 + "A].GPSBabel-1.3.2*Nov 01 2006*22:23:39" - gpsbabel 1.3.2 + + New since 11/01/2006: + version: version and release of gpsbabel (defined in configure.in) + timestamp: date and time of gdb.c (handled by CVS) + + "A].GPSBabel-1.3.2*Nov 01 2006*22:23:39" - gpsbabel 1.3.2 + "A].GPSBabel-beta20061125*Feb 06 2007*23:24:14" gpsbabel beta20061125 + "A].GPSBabel-1.3.3*Feb 20 2007*20:51:15" - gpsbabel 1.3.3 + */ + memset(&tm, 0, sizeof(tm)); sscanf(gdb_release_date+7, "%d/%d/%d %d:%d:%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); tm.tm_year -= 1900; @@ -1234,591 +1128,581 @@ gdb_write_file_header(void) c = buff; while ((c = strchr(c, '*'))) *c++ = '\0'; - gdb_fwrite_int(len); - gdb_fwrite_str(buff, len + 1); - - gdb_fwrite_str("MapSource", -1); /* MapSource magic */ + FWRITE_i32(len); + FWRITE(buff, len + 1); + FWRITE_CSTR("MapSource"); /* MapSource magic */ } +/*-----------------------------------------------------------------------------*/ + +/* + * gdb_check_waypt: As implemented in waypt_add, but we have some leaks where + * waypoints are modified after waypt_add. Maybe we need a data check + * after each input module. + */ + static void -gdb_reset_short_handle(void) +gdb_check_waypt(waypoint *wpt) { - if (gdb_short_handle != NULL) - mkshort_del_handle(&gdb_short_handle); - - gdb_short_handle = mkshort_new_handle(); - - setshort_length(gdb_short_handle, GDB_NAME_BUFFERLEN); - setshort_badchars(gdb_short_handle, ""); - setshort_mustupper(gdb_short_handle, 0); - setshort_mustuniq(gdb_short_handle, 1); - setshort_whitespace_ok(gdb_short_handle, 1); - setshort_repeating_whitespace_ok(gdb_short_handle, 1); + double lat_orig = wpt->latitude; + double lon_orig = wpt->longitude; + + if (wpt->latitude < -90) wpt->latitude += 180; + else if (wpt->latitude > +90) wpt->latitude -= 180; + if (wpt->longitude < -180) wpt->longitude += 360; + else if (wpt->longitude > +180) wpt->longitude -= 360; + + if ((wpt->latitude < -90) || (wpt->latitude > 90.0)) + fatal ("Invalid latitude %f in waypoint %s.\n", + lat_orig, wpt->shortname ? wpt->shortname : ""); + if ((wpt->longitude < -180) || (wpt->longitude > 180.0)) + fatal ("Invalid longitude %f in waypoint %s.\n", + lon_orig, wpt->shortname ? wpt->shortname : ""); } -/*******************************************************************************/ -/* %%% write waypoints %%% */ /*-----------------------------------------------------------------------------*/ -static void -gdb_write_waypt(const waypoint *wpt, const int hidden) +static void +write_waypoint( + const waypoint *wpt, const char *shortname, garmin_fs_t *gmsd, + const int icon, const int display) { - int i; - char ffbuf[32], zbuf[32]; - char c0 = 0; - char c1 = 1; - garmin_fs_t *gmsd; - unsigned char wpt_class; - char *ident; + char zbuf[32], ffbuf[32]; + int wpt_class; - gmsd = GMSD_FIND(wpt); + waypt_ct++; /* increase informational number of written waypoints */ - gdb_is_validf((fabs(wpt->latitude) <= 90), "wpt_write", - "%s: Invalid latitude (%f) detected\n", wpt->shortname, wpt->latitude); - + memset(zbuf, 0, sizeof(zbuf)); memset(ffbuf, 0xFF, sizeof(ffbuf)); - memset(zbuf, 0x00, sizeof(zbuf)); - - ident = wpt->shortname; /* paranoia */ - if (global_opts.synthesize_shortnames || (ident == NULL) || (*ident == '\0')) - { - ident = mkshort_from_wpt(gdb_short_handle, wpt); - } - gdb_fwrite_str(ident, -1); - - wpt_class = GMSD_GET(wpt_class, (hidden != 0) ? GDB_HIDDENROUTEWPTCLASS : GDB_DEFAULTWPTCLASS); - gdb_fwrite_int(wpt_class); /* class */ - gdb_fwrite_str(GMSD_GET(cc, ""), -1); /* country code */ - gdb_fwrite(zbuf, 4); /* subclass part 1 */ - gdb_fwrite(ffbuf, 12); /* subclass part 2 */ - gdb_fwrite(zbuf, 2); /* subclass part 3 */ - gdb_fwrite(ffbuf, 4); /* unknown */ + wpt_class = wpt->microseconds; /* trick */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->latitude)); - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->longitude)); + FWRITE_CSTR(shortname); /* uniqe (!!!) shortname */ + FWRITE_i32(wpt_class); /* waypoint class */ + FWRITE_CSTR(GMSD_GET(cc, "")); /* country code */ - gdb_fwrite_alt(wpt->altitude, unknown_alt); /* altitude */ - - gdb_fwrite_str((wpt->notes != NULL) ? wpt->notes : wpt->description, -1); /* notes/comment/descr */ - - gdb_fwrite_alt(GMSD_GET(proximity, 0), 0); /* proximity */ + if (wpt_class != 0) waypth_ct++; - switch(GMSD_GET(display, 0)) { /* display */ - case gt_display_mode_symbol: i = gt_gdb_display_mode_symbol; break; - case gt_display_mode_symbol_and_comment: i = gt_gdb_display_mode_symbol_and_comment; break; - default: i = gt_gdb_display_mode_symbol_and_name; break; +#ifdef GMSD_EXPERIMENTAL + if (gmsd && gmsd->flags.subclass && (wpt_class >= gt_waypt_class_map_point)) { + FWRITE(gmsd->subclass, sizeof(gmsd->subclass)); } - gdb_fwrite_int(i); - - gdb_fwrite_int(0); /* colour */ - - gdb_fwrite_icon(wpt); /* icon */ - gdb_fwrite_str(GMSD_GET(city, ""), -1); /* city */ - gdb_fwrite_str(GMSD_GET(state, ""), -1); /* state */ - gdb_fwrite_str(GMSD_GET(facility, ""), -1); /* facility */ - - gdb_fwrite(zbuf, 1); /* unknown */ - - gdb_fwrite_alt(GMSD_GET(depth, 0), 0); /* depth */ - - gdb_fwrite(zbuf, 3); /* three unknown bytes */ - gdb_fwrite(zbuf, 4); /* four unknown bytes */ - - if (hidden == 0) - gdb_fwrite_str(wpt->url, -1); /* URL */ else - gdb_fwrite_str(wpt->description, -1); /* description for hidden waypoints */ - - i = GMSD_GET(category, gdb_category); /* category */ - gdb_fwrite_le(&i, 2); - - gdb_fwrite_alt(GMSD_GET(temperature, 0), 0); /* temperature */ - - if (wpt->creation_time > 0) /* creation time */ +#endif { - gdb_fwrite(&c1, 1); - gdb_fwrite_int(wpt->creation_time); + FWRITE(zbuf, 4); /* subclass part 1 */ + FWRITE(ffbuf, 12); /* subclass part 2 */ + FWRITE(zbuf, 2); /* subclass part 3 */ + FWRITE(ffbuf, 4); /* unknown */ } - else - gdb_fwrite(&c0, 1); - -} -static void -gdb_write_waypt_cb(const waypoint *wpt) /* called by waypt_disp over all waypoints */ -{ - int reclen; - size_t pos; - waypoint *tmp; - - /* check for duplicate waypoints */ - if (NULL != gdb_find_wpt_q_by_name(&gdb_hidden, wpt->shortname)) - return; + FWRITE_LATLON(wpt->latitude); /* latitude */ + FWRITE_LATLON(wpt->longitude); /* longitude */ + FWRITE_DBL(wpt->altitude, unknown_alt); /* altitude */ + FWRITE_CSTR(wpt->notes); + FWRITE_DBL(WAYPT_GET(wpt, proximity, unknown_alt), unknown_alt); /* proximity */ + FWRITE_i32(display); /* display */ + FWRITE_i32(0); /* color (colour) */ + FWRITE_i32(icon); /* icon */ + FWRITE_CSTR(GMSD_GET(city, "")); /* city */ + FWRITE_CSTR(GMSD_GET(state, "")); /* state */ + FWRITE_CSTR(GMSD_GET(facility, "")); /* facility */ + FWRITE_C(0); /* unknown */ + FWRITE_DBL(WAYPT_GET(wpt, depth, unknown_alt), unknown_alt); /* depth */ + + /* VERSION DEPENDENT CODE */ + if (gdb_ver <= GDB_VER_2) { + char *descr; + + FWRITE(zbuf, 3); + FWRITE(zbuf, 4); + descr = (wpt_class < gt_waypt_class_map_point) ? + wpt->url : wpt->description; + if ((descr != NULL) && (wpt_class >= gt_waypt_class_map_point) && \ + (strcmp(descr, wpt->shortname) == 0)) + descr = NULL; + FWRITE_CSTR(descr); + } + else /* if (gdb_ver > GDB_VER_3) */ { + int cnt; + url_link *url_next; + char *str; - gdb_fwrite_int(0); - gdb_fwrite_str("W", 1); - - pos = ftell(fout); - gdb_write_waypt(wpt, 0); - reclen = ftell(fout) - pos; - - fseek(fout, pos - 5, SEEK_SET); - gdb_fwrite_int(reclen); - - fseek(fout, pos + reclen, SEEK_SET); + if (wpt_class < gt_waypt_class_map_point) /* street address */ + str = GMSD_GET(addr, ""); + else + str = ""; + FWRITE_CSTR(str); + FWRITE(zbuf, 5); /* instruction dependend */ + + /* GBD doesn't have a native description field */ + /* here we misuse the instruction field */ - tmp = waypt_dupe(wpt); - ENQUEUE_TAIL(&gdb_hidden, &tmp->Q); /* add this point to our internal queue */ + str = wpt->description; + if (str && (strcmp(str, wpt->shortname) == 0)) str = NULL; + if (str && wpt->notes && (strcmp(str, wpt->notes) == 0)) str = NULL; + FWRITE_CSTR(str); /* instruction */ + + cnt = 0; + if (wpt->url) cnt++; + for (url_next = wpt->url_next; (url_next); url_next = url_next->url_next) + if (url_next->url) cnt++; + FWRITE_i32(cnt); + if (wpt->url) FWRITE_CSTR(wpt->url); + for (url_next = wpt->url_next; (url_next); url_next = url_next->url_next) + if (url_next->url) FWRITE_CSTR(url_next->url); + } + + FWRITE_i16(GMSD_GET(category, gdb_category)); + FWRITE_DBL(WAYPT_GET(wpt, temperature, 0), 0); + FWRITE_TIME(wpt->creation_time); + + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_3) { + char *str = GMSD_GET(phone_nr, ""); + if (*str) { + FWRITE_i32(1); + FWRITE_CSTR(str); + FWRITE_CSTR(""); + } + else { + FWRITE_i32(0); + } + FWRITE_CSTR(GMSD_GET(country, "")); + FWRITE_CSTR(GMSD_GET(postal_code, "")); + } } static void -gdb_write_rtewpt_cb(const waypoint *wpt) /* called by waypt_disp (route points) */ +route_compute_bounds(const route_head *rte, bounds *bounds) { - int reclen; - size_t pos; - waypoint *tmp, *dupe; - - tmp = gdb_find_wpt_q_by_name(&gdb_hidden, wpt->shortname); - if (tmp == NULL) - { - tmp = find_waypt_by_name(wpt->shortname); - - gdb_fwrite_int(0); - gdb_fwrite_str("W", 1); - - pos = ftell(fout); - gdb_write_waypt(wpt, (tmp == NULL)); - reclen = ftell(fout) - pos; - - fseek(fout, pos - 5, SEEK_SET); - gdb_fwrite_int(reclen); - - fseek(fout, pos + reclen, SEEK_SET); - - dupe = waypt_dupe(wpt); - ENQUEUE_TAIL(&gdb_hidden, &dupe->Q); /* add this point to our internal queue */ + queue *elem, *tmp; + waypt_init_bounds(bounds); + QUEUE_FOR_EACH((queue *)&rte->waypoint_list, elem, tmp) { + waypoint *wpt = (waypoint *)elem; + gdb_check_waypt(wpt); + waypt_add_to_bounds(bounds, wpt); } } -/*******************************************************************************/ -/* %%% write routes %%% */ -/*-----------------------------------------------------------------------------*/ - static void -gdb_write_route(const route_head *route, const waypoint **list, const int count) +route_write_bounds(bounds *bounds) { - int i, wpt_class; - char buff[128], zbuff[32], ffbuff[32]; - waypoint *prev = NULL; - const char c0 = 0; - const char c1 = 1; - const char c3 = 3; - double maxlat = -90; - double minlat = +90; - double maxlon = -180; - double minlon = +180; - double maxalt = -unknown_alt; - double minalt = +unknown_alt; - - memset(zbuff, 0, sizeof(zbuff)); - memset(ffbuff, 0xFF, sizeof(ffbuff)); - - for (i = 0; i < count; i++) - { - const waypoint *wpt = list[i]; - - if (wpt->latitude > maxlat) maxlat = wpt->latitude; - if (wpt->latitude < minlat) minlat = wpt->latitude; - if (wpt->longitude > maxlon) maxlon = wpt->longitude; - if (wpt->longitude < minlon) minlon = wpt->longitude; - if (wpt->altitude != unknown_alt) - { - if (wpt->altitude > maxalt) maxalt = wpt->altitude; - if (wpt->altitude < minalt) minalt = wpt->altitude; - } - } - - { - char *cname; - - if (route->rte_name == NULL) - { - snprintf(buff, sizeof(buff), "Route%04d", route->rte_num); - cname = mkshort(gdb_short_handle, buff); - } - else - cname = mkshort(gdb_short_handle, route->rte_name); - - gdb_fwrite_str(cname, -1); - xfree(cname); + if (waypt_bounds_valid(bounds)) { + FWRITE_C(0); + FWRITE_LATLON(bounds->max_lat); + FWRITE_LATLON(bounds->max_lon); + FWRITE_DBL(bounds->max_alt, -(unknown_alt)); + FWRITE_LATLON(bounds->min_lat); + FWRITE_LATLON(bounds->min_lon); + FWRITE_DBL(bounds->min_alt, unknown_alt); } + else FWRITE_C(1); +} - gdb_fwrite(&c0, 1); /* auto_name */ +static void +write_route(const route_head *rte, const char *rte_name) +{ + bounds bounds; + int points, index; + queue *elem, *tmp; + char zbuf[32], ffbuf[32]; - if (count == 1) gdb_fwrite(&c1, 1); /* skip max data */ - else - { - gdb_fwrite(&c0, 1); /* ??? */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(maxlat)); /* maximum latitude over route */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(maxlon)); /* maximum longitude over route */ - gdb_fwrite_alt(maxalt, unknown_alt); /* maximum altitude over route */ - - gdb_fwrite_int(GPS_Math_Deg_To_Semi(minlat)); /* minimum latitude over route */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(minlon)); /* minimum longitude over route */ - gdb_fwrite_alt(minalt, -unknown_alt); /* minimum altitude over route */ - } + memset(zbuf, 0, sizeof(zbuf)); + memset(ffbuf, 0xFF, sizeof(ffbuf)); - gdb_fwrite_int(count); /* number of points in route */ - - for (i = 0; i < count; i++) - { - const waypoint *wpt = list[i]; - garmin_fs_t *gmsd; - - gmsd = GMSD_FIND(wpt); - if (gmsd && gmsd->flags.wpt_class) - wpt_class = gmsd->wpt_class; - else - wpt_class = gdb_detect_rtept_class(wpt); - - if (prev != NULL) - { - gdb_fwrite_int(2); /* route link details */ + FWRITE_CSTR(rte_name); + FWRITE_C(0); /* display/autoname - 1 byte */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(prev->latitude)); /* ilink step 1 (end point 1) */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(prev->longitude)); - gdb_fwrite_alt(prev->altitude, unknown_alt); + route_compute_bounds(rte, &bounds); + route_write_bounds(&bounds); - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->latitude)); /* ilink step 2 (end point 2) */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->longitude)); - gdb_fwrite_alt(wpt->altitude, unknown_alt); + points = ELEMENTS(rte); + FWRITE_i32(points); + + index = 0; + + QUEUE_FOR_EACH((queue *)&rte->waypoint_list, elem, tmp) { + + waypoint *wpt = (waypoint *)elem; + waypoint *next = (waypoint *)tmp; + waypoint *test; + garmin_fs_t *gmsd = NULL; + int wpt_class; - if (wpt->latitude > prev->latitude) /* get maximum lat, lon and alt */ - { - maxlat = wpt->latitude; - minlat = prev->latitude; - } - else - { - maxlat = prev->latitude; - minlat = wpt->latitude; - } - if (wpt->longitude > prev->longitude) - { - maxlon = wpt->longitude; - minlon = prev->longitude; + index++; + rtept_ct++; /* increase informational number of written route points */ + + if (index == 1) gdb_check_waypt(wpt); + if (index < points) gdb_check_waypt(next); + + test = gdb_find_wayptq(&wayptq_out, wpt, 1); + if (test != NULL) wpt = test; + else { + fatal(MYNAME ": Sorry, that should never happen!!!\n"); } + + gmsd = GMSD_FIND(wpt); + + /* extra_data may contain a modified shortname */ + FWRITE_CSTR((wpt->extra_data) ? (char *)wpt->extra_data : wpt->shortname); + + wpt_class = wpt->microseconds; /* trick */ + + FWRITE_i32(wpt_class); /* waypoint class */ + FWRITE_CSTR(GMSD_GET(cc, "")); /* country */ +#ifdef GMSD_EXPERIMENTAL + if (gmsd && gmsd->flags.subclass && (wpt_class >= gt_waypt_class_map_point)) + FWRITE(gmsd->subclass, sizeof(gmsd->subclass)); else +#endif { - maxlon = prev->longitude; - minlon = wpt->longitude; + FWRITE(zbuf, 4); /* subclass part 1 */ + FWRITE(ffbuf, 12); /* subclass part 2 */ + FWRITE(zbuf, 2); /* subclass part 3 */ + FWRITE(ffbuf, 4); /* unknown */ } - if (wpt->altitude != unknown_alt) - { - maxalt = wpt->altitude; - minalt = wpt->altitude; - } - else - { - maxalt = -unknown_alt; - minalt = +unknown_alt; + + FWRITE_C(0); /* unknown value or string */ + FWRITE_C(3); /* unknown 18 bytes starting with 0x03 */ + FWRITE(zbuf, 3); + FWRITE(ffbuf, 4); + FWRITE(zbuf, 10); + + if (index == points) { + FWRITE_i32(0); /* no more steps */ + FWRITE_C(1); /* skip bounds */ } - if (prev->altitude != unknown_alt) - { - if (prev->altitude > maxalt) maxalt = prev->altitude; - if (prev->altitude < minalt) minalt = prev->altitude; + else /* if (index < points) */ { + FWRITE_i32(2); /* two interstep links */ + + FWRITE_LATLON(wpt->latitude); + FWRITE_LATLON(wpt->longitude); + FWRITE_DBL(wpt->altitude, unknown_alt); + FWRITE_LATLON(next->latitude); + FWRITE_LATLON(next->longitude); + FWRITE_DBL(next->altitude, unknown_alt); + + waypt_init_bounds(&bounds); + waypt_add_to_bounds(&bounds, wpt); + waypt_add_to_bounds(&bounds, next); + route_write_bounds(&bounds); + } - gdb_fwrite(&c0, 1); /* ??? */ - - gdb_fwrite_int(GPS_Math_Deg_To_Semi(maxlat)); /* maximum coords & altitude */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(maxlon)); - gdb_fwrite_alt(maxalt, unknown_alt); - - gdb_fwrite_int(GPS_Math_Deg_To_Semi(minlat)); /* minimum coords & altitude */ - gdb_fwrite_int(GPS_Math_Deg_To_Semi(minlon)); - gdb_fwrite_alt(minalt, -unknown_alt); - - if (gdb_ver >= 2) - gdb_fwrite(ffbuff, 8); - } - - gdb_fwrite_str(wpt->shortname, -1); /* short name */ - - gdb_fwrite_int(wpt_class); /* class */ - gdb_fwrite_str(GMSD_GET(cc, ""), -1); /* country */ - - gdb_fwrite(zbuff, 4); /* subclass part 1 */ - gdb_fwrite(ffbuff, 12); /* subclass part 2 */ - gdb_fwrite(zbuff, 2); /* subclass part 3 */ - gdb_fwrite(ffbuff, 4); /* unknown */ - - gdb_fwrite(&c0, 1); /* unknown value or string */ - gdb_fwrite(&c3, 1); /* unknown 18 bytes starting with 0x03 */ - gdb_fwrite(zbuff, 3); - gdb_fwrite(ffbuff, 4); - gdb_fwrite(zbuff, 10); - - prev = (waypoint *)wpt; + /* VERSION DEPENDENT CODE */ + if (gdb_ver >= GDB_VER_2) { + FWRITE(ffbuf, 8); + if (gdb_ver >= GDB_VER_3) + FWRITE(zbuf, 2); + } } - - gdb_fwrite_int(0); /* Zero interlink steps */ - gdb_fwrite(&c1, 1); - if (gdb_ver >= 2) - gdb_fwrite(ffbuff, 8); - - gdb_fwrite_str(route->rte_url, -1); + /* VERSION DEPENDENT CODE */ + if (gdb_ver <= GDB_VER_2) { + FWRITE_CSTR(rte->rte_url); + } + else /* if (gdb_ver >= GDB_VER_3) */ { + FWRITE_CSTR_LIST(rte->rte_url); + FWRITE_i32(0x0E); /* color ??? */ + FWRITE_C(0); + FWRITE_CSTR(rte->rte_desc); + } } static void -gdb_write_route_cb(const route_head *route) +write_track(const route_head *trk, const char *trk_name) { - int reclen; - size_t pos; - int count; - waypoint **list; + queue *elem, *tmp; + int points = ELEMENTS(trk); - list = gdb_route_point_list(route, &count); - if (count == 0) return; /* don't write empty routes */ + FWRITE_CSTR(trk_name); + FWRITE_C(0); + FWRITE_i32(0); - gdb_fwrite_int(0); - gdb_fwrite_str("R", 1); - - pos = ftell(fout); - gdb_write_route(route, (const waypoint**)list, count); - reclen = ftell(fout) - pos; - - fseek(fout, pos - 5, SEEK_SET); - gdb_fwrite_int(reclen); + FWRITE_i32(points); /* total number of waypoints in waypoint list */ - fseek(fout, pos + reclen, SEEK_SET); + QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) + { + double d; + waypoint *wpt = (waypoint *)elem; + + trkpt_ct++; /* increase informational number of written route points */ + + FWRITE_LATLON(wpt->latitude); + FWRITE_LATLON(wpt->longitude); + FWRITE_DBL(wpt->altitude, unknown_alt); + FWRITE_TIME(wpt->creation_time); + d = WAYPT_GET(wpt, depth, unknown_alt); + FWRITE_DBL(d, unknown_alt); + d = WAYPT_GET(wpt, temperature, -99999); + FWRITE_DBL(d, -99999); + } + + /* finalize track */ - xfree(list); + /* VERSION DEPENDENT CODE */ + if (gdb_ver <= GDB_VER_2) { + FWRITE_CSTR(trk->rte_url); + } + else /* if (gdb_ver >= GDB_VER_3 */ { + FWRITE_CSTR_LIST(trk->rte_url); + } } -/*******************************************************************************/ -/* %%% write tracks %%% */ /*-----------------------------------------------------------------------------*/ -static void -gdb_write_track(const route_head *track) +static void +finalize_item(const gbsize_t anchor) { - char buff[128]; - const char c0 = 0; - const char c1 = 1; - queue *elem, *tmp; - int count = track->rte_waypt_ct; - - { - char *cname; - - if (track->rte_name == NULL) - { - snprintf(buff, sizeof(buff), "Track%04d", track->rte_num); - cname = mkshort(gdb_short_handle, buff); - } - else - cname = mkshort(gdb_short_handle, track->rte_name); - - gdb_fwrite_str(cname, -1); - xfree(cname); - } - - gdb_fwrite(&c0, 1); /* display */ - gdb_fwrite_int(0); /* xcolour */ - gdb_fwrite_int(count); + gbsize_t mark; + int len; - QUEUE_FOR_EACH((queue *)&track->waypoint_list, elem, tmp) - { - waypoint *wpt = (waypoint *)elem; - - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->latitude)); - gdb_fwrite_int(GPS_Math_Deg_To_Semi(wpt->longitude)); - gdb_fwrite_alt(wpt->altitude, unknown_alt); /* altitude */ - + mark = gbftell(fout); + len = mark - anchor; + gbfseek(fout, -(len + 5), SEEK_CUR); + FWRITE_i32(mark - anchor); + gbfseek(fout, len + 1, SEEK_CUR); +} - if (wpt->creation_time > 0) /* creation time */ - { - gdb_fwrite(&c1, 1); - gdb_fwrite_int(wpt->creation_time); - } - else - gdb_fwrite(&c0, 1); - - gdb_fwrite_alt(wpt->depth, unknown_alt); /* depth */ - gdb_fwrite(&c0, 1); /* temperature */ +/*-----------------------------------------------------------------------------*/ + +static char +str_not_equal(const char *s1, const char *s2) +{ + if (s1) { + if (!s2) return 1; + if (strcmp(s1, s2) != 0) return 1; + else return 0; } - gdb_fwrite_str(track->rte_url, -1); + else if (s2) return 1; + else return 0; } static void -gdb_write_track_cb(const route_head *track) /* called from track_disp_all */ +write_waypoint_cb(const waypoint *refpt) { - int reclen; - size_t pos; - - if (track->rte_waypt_ct <= 0) return; /* don't write empty tracks */ - - gdb_fwrite_int(0); - gdb_fwrite_str("T", 1); - - pos = ftell(fout); - - gdb_write_track(track); + garmin_fs_t *gmsd; + waypoint *test; + gbsize_t anchor; - reclen = ftell(fout) - pos; - fseek(fout, pos - 5, SEEK_SET); - gdb_fwrite_int(reclen); + /* do this when backup always happens in main */ - fseek(fout, pos + reclen, SEEK_SET); -} + rtrim(((waypoint *)refpt)->shortname); + test = gdb_find_wayptq(&wayptq_out, refpt, 1); -/*******************************************************************************/ + if ((test != NULL) && (route_flag == 0)) { + if ((str_not_equal(test->notes, refpt->notes)) || + (str_not_equal(test->url, refpt->url))) + test = NULL; + } -static void -gdb_write_data(void) -{ - queue *temp, *elem; - char c1 = 1; + if (test == NULL) { + int icon, display, wpt_class; + char *name; + waypoint *wpt = waypt_dupe(refpt); + + gdb_check_waypt(wpt); + ENQUEUE_TAIL(&wayptq_out, &wpt->Q); + + FWRITE_i32(-1); + FWRITE_C('W'); + anchor = gbftell(fout); + + /* prepare the waypoint */ + gmsd = GMSD_FIND(wpt); - QUEUE_INIT(&gdb_hidden); /* contains all written waypts & rtepts */ + wpt_class = GMSD_GET(wpt_class, -1); + if (wpt_class == -1) + wpt_class = (route_flag) ? GDB_DEF_HIDDEN_CLASS : GDB_DEF_CLASS; + wpt->microseconds = wpt_class; /* trick, we need this for the route(s) */ + + icon = GMSD_GET(icon, -1); + if (icon < 0) { + if (wpt->icon_descr) + icon = gt_find_icon_number_from_desc(wpt->icon_descr, GDB); + else + icon = GDB_DEF_ICON; + } - /* (doing_wpts) */ - - gdb_reset_short_handle(); - waypt_disp_all(gdb_write_waypt_cb); - - /* (doing_rtes) */ - - gdb_reset_short_handle(); - setshort_defname(gdb_short_handle, "Route"); - if (gdb_via == 0) - { - /* find out all route points we have to write as a "HIDDEN CLASS" waypoint */ - route_disp_all(NULL, NULL, gdb_write_rtewpt_cb); - } - route_disp_all(gdb_write_route_cb, NULL, NULL); - QUEUE_FOR_EACH(&gdb_hidden, elem, temp) { /* vaporize our temporary queue */ - waypt_free((waypoint *) elem); - } + switch(GMSD_GET(display, -1)) { /* display */ + case -1: + if (wpt_class < 8) + display = gt_gdb_display_mode_symbol_and_name; + else + display = gt_gdb_display_mode_symbol; + break; + case gt_display_mode_symbol: + display = gt_gdb_display_mode_symbol; + break; + case gt_display_mode_symbol_and_comment: + display = gt_gdb_display_mode_symbol_and_comment; + break; + default: + display = gt_gdb_display_mode_symbol_and_name; + break; + } - /* (doing_trks) */ - - gdb_reset_short_handle(); - setshort_defname(gdb_short_handle, "Track"); - track_disp_all(gdb_write_track_cb, NULL, NULL); + name = wpt->shortname; + + if (global_opts.synthesize_shortnames || (*name == '\0')) { + name = wpt->notes; + if (!name) name = wpt->description; + if (!name) name = wpt->shortname; + } + + name = mkshort(short_h, name); + wpt->extra_data = (void *)name; + write_waypoint(wpt, name, gmsd, icon, display); - gdb_fwrite_int(2); /* finalize gdb with empty map segment */ - gdb_fwrite_str("V", -1); - gdb_fwrite(&c1, 1); + finalize_item(anchor); + } } -/*******************************************************************************/ - static void -gdb_init_opts(const char op) /* 1 = read; 2 = write */ +write_route_cb(const route_head *rte) { - gdb_via = 0; - gdb_category = 0; - gdb_ver = 2; + gbsize_t anchor; + char *name; + char buf[32]; - if (gdb_opt_via != NULL) /* opt_via present in both ops */ - { - if ((case_ignore_strcmp(gdb_opt_via, GDB_OPT_VIA) == 0) || - (*gdb_opt_via == '\0')) - gdb_via = 1; - else - gdb_via = atoi(gdb_opt_via); - } + if (ELEMENTS(rte) <= 0) return; - if (op & 2) /* writer opts */ - { - if ((gdb_opt_category != NULL) && - (case_ignore_strcmp(gdb_opt_category, GDB_OPT_CATEGORY) != 0) && - (*gdb_opt_category != '\0')) - { - gdb_category = atoi(gdb_opt_category); - if ((gdb_category < 1) || (gdb_category > 16)) - fatal(MYNAME ": Unsupported category \"%s\"!\n", gdb_opt_category); - gdb_category = 1 << (gdb_category - 1); - } - - gdb_ver = atoi(gdb_opt_ver); - if ((gdb_ver < GDB_VER_MIN) || (gdb_ver > GDB_VER_MAX)) - fatal(MYNAME ": Unsupported version \"%s\"!\n", gdb_opt_ver); + if (rte->rte_name == NULL) { + snprintf(buf, sizeof(buf), "Route%04d", rte->rte_num); + name = mkshort(short_h, buf); } -} + else + name = mkshort(short_h, rte->rte_name); + + rte_ct++; /* increase informational number of written routes */ -/*******************************************************************************/ -/* %%% global cb's %%% */ -/*******************************************************************************/ + FWRITE_i32(-1); + FWRITE_C('R'); -static void -gdb_rd_init(const char *fname) -{ - gdb_init_opts(1); - - fin_name = xstrdup(fname); - fin = xfopen(fname, "rb", MYNAME); - gdb_read_file_header(); - - if (gdb_ver >= 3) cet_convert_init(CET_CHARSET_UTF8, 1); + anchor = gbftell(fout); + write_route(rte, name); + finalize_item(anchor); + + xfree(name); } static void -gdb_wr_init(const char *fname) +write_track_cb(const route_head *trk) { - gdb_init_opts(2); + gbsize_t anchor; + char *name; + char buf[32]; - fout_name = xstrdup(fname); - fout = xfopen(fname, "wb", MYNAME); - gdb_short_handle = NULL; - QUEUE_INIT(&gdb_hidden); -} + if (ELEMENTS(trk) <= 0) return; + + if (trk->rte_name == NULL) { + snprintf(buf, sizeof(buf), "Track%04d", trk->rte_num); + name = mkshort(short_h, buf); + } + else + name = mkshort(short_h, trk->rte_name); -static void -gdb_rd_deinit(void) -{ - fclose(fin); - xfree(fin_name); - fin_name = NULL; + trk_ct++; /* increase informational number of written tracks */ + + FWRITE_i32(-1); + FWRITE_C('T'); + + anchor = gbftell(fout); + write_track(trk, name); + finalize_item(anchor); + + xfree(name); } +/*-----------------------------------------------------------------------------*/ + static void -gdb_wr_deinit(void) +init_writer(const char *fname) { - fclose(fout); - xfree(fout_name); - fout_name = NULL; - mkshort_del_handle(&gdb_short_handle); + fout = gbfopen_le(fname, "wb", MYNAME); + + gdb_category = (gdb_opt_category) ? atoi(gdb_opt_category) : 0; + gdb_ver = (gdb_opt_ver && *gdb_opt_ver) ? atoi(gdb_opt_ver) : 0; + + if (gdb_ver >= GDB_VER_UTF8) + cet_convert_init(CET_CHARSET_UTF8, 1); + + QUEUE_INIT(&wayptq_out); + short_h = NULL; + + waypt_ct = 0; + waypth_ct = 0; + rtept_ct = 0; + trkpt_ct = 0; + rte_ct = 0; + trk_ct = 0; } -static void -gdb_read(void) +static void +done_writer(void) { - gdb_read_data(); + disp_summary(fout); + gdb_flush_waypt_queue(&wayptq_out); + mkshort_del_handle(&short_h); + gbfclose(fout); } static void -gdb_write(void) +write_data(void) { - gdb_write_file_header(); - gdb_write_data(); + if (gdb_opt_ver) gdb_ver = atoi(gdb_opt_ver); + write_header(); + + reset_short_handle("WPT"); + route_flag = 0; + waypt_disp_all(write_waypoint_cb); + route_flag = 1; + route_disp_all(NULL, NULL, write_waypoint_cb); + + reset_short_handle("Route"); + route_disp_all(write_route_cb, NULL, NULL); + + reset_short_handle("Track"); + track_disp_all(write_track_cb, NULL, NULL); + + FWRITE_i32(2); /* finalize gdb with empty map segment */ + FWRITE_CSTR("V"); + FWRITE_C(1); } /*******************************************************************************/ +#define GDB_OPT_VER "ver" +#define GDB_OPT_VIA "via" +#define GDB_OPT_CATEGORY "cat" +#define GDB_OPT_ROADBOOK "roadbook" + +static arglist_t gdb_args[] = { + {GDB_OPT_CATEGORY, &gdb_opt_category, + "Default category on output (1..16)", + NULL, ARGTYPE_INT, "1", "16"}, + {GDB_OPT_VER, &gdb_opt_ver, + "Version of gdb file to generate (1..3)", + "2", ARGTYPE_INT, "1", "3"}, + {GDB_OPT_VIA, &gdb_opt_via, + "Drop route points that do not have an equivalent waypoint (hidden points)", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + {GDB_OPT_ROADBOOK, &gdb_opt_roadbook, + "Include major turn points (with description) from calculated route", + NULL, ARGTYPE_BOOL, ARG_NOMINMAX}, + ARG_TERMINATOR +}; + ff_vecs_t gdb_vecs = { ff_type_file, FF_CAP_RW_ALL, - gdb_rd_init, - gdb_wr_init, - gdb_rd_deinit, - gdb_wr_deinit, - gdb_read, - gdb_write, + init_reader, + init_writer, + done_reader, + done_writer, + read_data, + write_data, NULL, gdb_args, CET_CHARSET_MS_ANSI, 0 /* O.K.: changed to NON-FIXED */ diff --git a/geo.c b/geo.c index 9dbd84c9b..47d3f26f3 100644 --- a/geo.c +++ b/geo.c @@ -216,7 +216,7 @@ geo_write(void) ff_vecs_t geo_vecs = { ff_type_file, - FF_CAP_RW_WPT, + { ff_cap_read | ff_cap_write, ff_cap_none, ff_cap_none }, geo_rd_init, geo_wr_init, geo_rd_deinit, diff --git a/geoniche.c b/geoniche.c index 7be79803c..d9a6c0f53 100644 --- a/geoniche.c +++ b/geoniche.c @@ -22,8 +22,7 @@ #include "defs.h" #if PDBFMTS_ENABLED -#include "coldsync/palm.h" -#include "coldsync/pdb.h" +#include "pdbfile.h" #include "jeeps/gpsmath.h" #include "garmin_tables.h" @@ -37,11 +36,10 @@ #undef GEONICHE_DBG -static FILE *FileIn; -static FILE *FileOut; +static pdbfile *file_in, *file_out; static const char *FilenameOut; -static struct pdb *PdbOut; - +static int rec_ct; +static int ct; static char Rec0Magic[] = "68000NV4Q2"; static char *Arg_dbname = NULL; @@ -118,13 +116,13 @@ id2gid(char gid[6+1], int id) static void rd_init(const char *fname) { - FileIn = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); } static void rd_deinit(void) { - fclose(FileIn); + pdb_close(file_in); ARG_FREE(Arg_dbname); ARG_FREE(Arg_category); } @@ -132,14 +130,14 @@ rd_deinit(void) static void wr_init(const char *fname) { - FileOut = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); FilenameOut = fname; } static void wr_deinit(void) { - fclose(FileOut); + pdb_close(file_out); ARG_FREE(Arg_dbname); ARG_FREE(Arg_category); } @@ -190,12 +188,12 @@ eof: } static void -geoniche_read_asc(const struct pdb *pdb) +geoniche_read_asc(void) { - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; /* Process record 0 */ - pdb_rec = pdb->rec_index.rec; + pdb_rec = file_in->rec_list; if (strcmp((char *) pdb_rec->data, Rec0Magic)) fatal(MYNAME ": Bad record 0, not a GeoNiche file.\n"); pdb_rec = pdb_rec->next; @@ -225,7 +223,7 @@ geoniche_read_asc(const struct pdb *pdb) if (!wpt) fatal(MYNAME ": Couldn't allocate waypoint.\n"); vdata = (char *) pdb_rec->data; - vlen = pdb_rec->data_len; + vlen = pdb_rec->size; /* Field 1: Target */ p = field(&vdata, &vlen); @@ -436,13 +434,13 @@ geoniche_icon_to_descr(const int no) } static void -geoniche_read_bin(const struct pdb *pdb) +geoniche_read_bin(void) { - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; /* Process records */ - for (pdb_rec = pdb->rec_index.rec; pdb_rec != NULL; pdb_rec = pdb_rec->next) + for (pdb_rec = file_in->rec_list; pdb_rec != NULL; pdb_rec = pdb_rec->next) { char *vdata = (char *) pdb_rec->data; struct tm created, visited; @@ -516,27 +514,20 @@ geoniche_read_bin(const struct pdb *pdb) static void data_read(void) { - struct pdb *pdb; - - if (NULL == (pdb = pdb_Read(fileno(FileIn)))) - fatal(MYNAME ": pdb_Read failed\n"); - - if (pdb->creator != MYCREATOR) + if (file_in->creator != MYCREATOR) fatal(MYNAME ": Not a GeoNiche file.\n"); - switch(pdb->type) + switch(file_in->type) { case MYTYPE_ASC: - geoniche_read_asc(pdb); + geoniche_read_asc(); break; case MYTYPE_BIN: - geoniche_read_bin(pdb); + geoniche_read_bin(); break; default: fatal(MYNAME ": Unsupported GeoNiche file.\n"); } - - free_pdb(pdb); } static char * @@ -666,11 +657,8 @@ geoniche_geostuff(const waypoint *wpt) static void geoniche_writewpt(const waypoint *wpt) { - static int ct = 0; - struct pdb_record *opdb_rec; int vlen; - static int vsize = 4096; - ubyte *vdata; + char *vdata; char *title; struct tm tm; char datestr[10+1]; @@ -680,13 +668,8 @@ geoniche_writewpt(const waypoint *wpt) time_t tx; char *gs; - if (ct == 0) - { - opdb_rec = new_Record (0, 0, ct++, sizeof(Rec0Magic), (ubyte *) Rec0Magic); - if (opdb_rec == NULL) - fatal(MYNAME ": libpdb couldn't create record\n"); - if (pdb_AppendRecord(PdbOut, opdb_rec)) - fatal(MYNAME ": libpdb couldn't append record\n"); + if (rec_ct == 0) { + pdb_write_rec(file_out, 0, 0, ct++, Rec0Magic, sizeof(Rec0Magic)); } if ( wpt->description && wpt->description[0] ) @@ -696,7 +679,7 @@ geoniche_writewpt(const waypoint *wpt) id = gid2id(wpt->shortname); if (id < 0) - id = ct; + id = rec_ct; tx = (wpt->creation_time != 0) ? wpt->creation_time : gpsbabel_time; if (tx == 0) { /* maybe zero during testo (freezed time) */ @@ -723,13 +706,7 @@ geoniche_writewpt(const waypoint *wpt) /* last chance to fill notes with something */ if (*notes == '\0') notes = xstrappend(notes, "(notes)"); - vdata = (ubyte *) xmalloc(vsize); - if (vdata == NULL) - fatal(MYNAME ": libpdb couldn't get record memory\n"); - - for (;;) - { - vlen = snprintf((char *) vdata, vsize, + vlen = xasprintf(&vdata, "Target,%d,%s,,%s,%f,%f,%f,%s,%s,,,,%d,,,,%s" , id , title @@ -750,58 +727,37 @@ geoniche_writewpt(const waypoint *wpt) , notes ); - if (vlen > -1 && vlen < vsize) - break; - - /* try again with more space. */ - if (vlen > -1) - vsize = vlen + 1; - else - vsize *= 2; - vdata = (ubyte *) xrealloc(vdata, vsize); - if (vdata == NULL) - fatal(MYNAME ": libpdb couldn't get record memory\n"); - } - - opdb_rec = new_Record (0, 0, ct++, (uword) (vlen+1), vdata); - - if (opdb_rec == NULL) - fatal(MYNAME ": libpdb couldn't create record\n"); - if (pdb_AppendRecord(PdbOut, opdb_rec)) - fatal(MYNAME ": libpdb couldn't append record\n"); + pdb_write_rec(file_out, 0, 0, ct++, vdata, vlen + 1); xfree(notes); xfree(title); xfree(vdata); + + rec_ct++; } static void data_write(void) { - if (NULL == (PdbOut = new_pdb())) - fatal (MYNAME ": new_pdb failed\n"); - if (Arg_dbname) { if (case_ignore_strcmp(Arg_dbname, "GeoNiche Targets") == 0) fatal(MYNAME ": Reserved database name!\n"); - strncpy(PdbOut->name, Arg_dbname, PDB_DBNAMELEN); + strncpy(file_out->name, Arg_dbname, PDB_DBNAMELEN); } else - strncpy(PdbOut->name, FilenameOut, PDB_DBNAMELEN); - PdbOut->name[PDB_DBNAMELEN-1] = 0; - - PdbOut->attributes = PDB_ATTR_BACKUP; - PdbOut->ctime = PdbOut->mtime = current_time() + (49*365 + 17*366) * (60*60*24); - PdbOut->type = MYTYPE_ASC; - PdbOut->creator = MYCREATOR; - PdbOut->version = 0; - PdbOut->modnum = 1; - + strncpy(file_out->name, FilenameOut, PDB_DBNAMELEN); + file_out->name[PDB_DBNAMELEN-1] = 0; + + file_out->attr = PDB_FLAG_BACKUP; + file_out->ctime = file_out->mtime = current_time() + (49*365 + 17*366) * (60*60*24); + file_out->type = MYTYPE_ASC; + file_out->creator = MYCREATOR; + file_out->version = 0; + file_out->revision = 1; + + rec_ct = 0; + ct = 0; waypt_disp_all(geoniche_writewpt); - - pdb_Write(PdbOut, fileno(FileOut)); - - free_pdb(PdbOut); } diff --git a/ggv_log.c b/ggv_log.c new file mode 100644 index 000000000..ef31cba31 --- /dev/null +++ b/ggv_log.c @@ -0,0 +1,276 @@ +/* + + Support for "GeoGrid Viewer" binary tracklogs (*.log) + + Copyright (C) 2007 Olaf Klein, o.b.klein@gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ + +#include +#include + +#include "defs.h" +#include "grtcirc.h" +#include "jeeps/gpsmath.h" + +#define MYNAME "ggv_log" + +static gbfile *fin, *fout; +static int ggv_log_ver; + +static +arglist_t ggv_log_args[] = { + ARG_TERMINATOR +}; + +/******************************************************************************* +* %%% global callbacks called by gpsbabel main process %%% * +*******************************************************************************/ + +static void +ggv_log_rd_init(const char *fname) +{ + static char magic[32]; + int len = 0; + + fin = gbfopen(fname, "rb", MYNAME); + + for (;;) { + int cin; + + cin = gbfgetc(fin); + if (cin < 0) break; + + magic[len++] = cin; + + if (cin == '\0') { + double ver = 0; + char *sver; + if (strncmp(magic, "DOMGVGPS Logfile V", 18) != 0) break; + + sver = &magic[18]; + sscanf(sver, "%lf:", &ver); + ggv_log_ver = ver * 10; + if ((ggv_log_ver == 10) || (ggv_log_ver == 25)) return; /* header accepted */ + + fatal(MYNAME ": Sorry, unsupported version (%s)!\n", sver); + } + else if (len == sizeof(magic)) + break; + } + fatal(MYNAME ": Invalid header. Probably no " MYNAME " file!\n"); +} + +static void +ggv_log_rd_deinit(void) +{ + gbfclose(fin); +} + +static void +ggv_log_read(void) +{ + signed char *buf; + int bufsz = 0, len; + route_head *trk = NULL; + + switch(ggv_log_ver) { + case 10: bufsz = 0x2A; break; + case 25: bufsz = 0x6F; break; + } + + buf = xmalloc(bufsz); + + while ((len = gbfread(buf, 1, bufsz, fin))) { + int deg, min; + double xlat, xlon; + float sec; + struct tm tm; + waypoint *wpt; + + if (len != bufsz) break; + + if (trk == NULL) { + trk = route_head_alloc(); + track_add_head(trk); + } + + memset(&tm, 0, sizeof(tm)); + + wpt = waypt_new(); + + deg = (gbint16) le_read16(&buf[0]); + min = le_read16(&buf[2]); + sec = le_read_float(&buf[4]); + xlat = (double)deg + ((double)min / (double)60) + (sec / (double)3600.0); + wpt->latitude = xlat; + + deg = (gbint16) le_read16(&buf[8]); + min = le_read16(&buf[10]); + sec = le_read_float(&buf[12]); + xlon = (double)deg + ((double)min / (double)60) + (sec / (double)3600.0); + wpt->longitude = xlon; + + WAYPT_SET(wpt, course, le_read16(&buf[16 + 0])); + + if (ggv_log_ver == 10) { + double secs; + + wpt->altitude = le_read16(&buf[16 + 2]); + WAYPT_SET(wpt, speed, le_read16(&buf[16 + 4])); + tm.tm_year = le_read16(&buf[16 + 8]); + tm.tm_mon = le_read16(&buf[16 + 10]); + tm.tm_mday = le_read16(&buf[16 + 12]); + tm.tm_hour = le_read16(&buf[16 + 14]); + tm.tm_min = le_read16(&buf[16 + 16]); + secs = le_read_double(&buf[16 + 18]); + tm.tm_sec = (int)secs; + wpt->microseconds = (secs - tm.tm_sec) * 1000000; + } + else { + wpt->altitude = le_read16(&buf[16 + 4]); + wpt->sat = (unsigned char)buf[16 + 14]; + + /* other probably valid double values at offset: + + 22: 0.0 - 20.0 + 43: 0.0 - 59.0 + 51: -1.0 + 61: -1.0 + 79: .. - 20.0 ? speed over ground ? (++) + 87: ? course ? + 95: 0.0 - 3.1 (++) + 103: -1 + + */ + } + + if (wpt->altitude == 0) + wpt->altitude = unknown_alt; + + if (tm.tm_year >= 1900) { + tm.tm_year -= 1900; + if (tm.tm_mon > 0) { + tm.tm_mon--; + wpt->creation_time = mkgmtime(&tm); + } + } + + track_add_wpt(trk, wpt); + } + xfree(buf); +} + +static void +ggv_log_wr_init(const char *fname) +{ + fout = gbfopen(fname, "wb", MYNAME); + + gbfputcstr("DOMGVGPS Logfile V1.0:", fout); +} + +static void +ggv_log_wr_deinit(void) +{ + gbfclose(fout); +} + +static void +ggv_log_track_head_cb(const route_head *trk) +{ + queue *elem, *tmp; + waypoint *prev = NULL; + + QUEUE_FOR_EACH((queue *)&trk->waypoint_list, elem, tmp) { + double latmin, lonmin, latsec, lonsec; + int latint, lonint; + double course = 0, speed = 0; + struct tm tm; + waypoint *wpt = (waypoint *)elem; + double secs = 0; + + latint = wpt->latitude; + lonint = wpt->longitude; + latmin = 60.0 * (fabs(wpt->latitude) - latint); + lonmin = 60.0 * (fabs(wpt->longitude) - lonint); + latsec = 60.0 * (latmin - floor(latmin)); + lonsec = 60.0 * (lonmin - floor(lonmin)); + + if (wpt->creation_time > 0) { + tm = *gmtime(&wpt->creation_time); + tm.tm_mon += 1; + tm.tm_year += 1900; + } + else + memset(&tm, 0, sizeof(tm)); + + if (prev != NULL) { + course = heading_true_degrees( + prev->latitude, prev->longitude, + wpt->latitude, wpt->longitude); + speed = waypt_speed(prev, wpt); + } + if (wpt->creation_time > 0) + secs = (double)tm.tm_sec + ((double)wpt->microseconds / 1000000); + + gbfputint16((gbint16) latint, fout); + gbfputint16((gbint16) latmin, fout); + gbfputflt(latsec, fout); + gbfputint16((gbint16) lonint, fout); + gbfputint16((gbint16) lonmin, fout); + gbfputflt(lonsec, fout); + gbfputint16((gbint16) course, fout); + gbfputint16((gbint16) (wpt->altitude != unknown_alt) ? wpt->altitude : 0, fout); + gbfputint16((gbint16) speed, fout); + gbfputint16(0, fout); + gbfputint16(tm.tm_year, fout); + gbfputint16(tm.tm_mon, fout); + gbfputint16(tm.tm_mday, fout); + gbfputint16(tm.tm_hour, fout); + gbfputint16(tm.tm_min, fout); + gbfputdbl(secs, fout); + + prev = wpt; + } +} + +static void +ggv_log_write(void) +{ + track_disp_all(ggv_log_track_head_cb, NULL, NULL); +} + +/**************************************************************************/ + +ff_vecs_t ggv_log_vecs = { + ff_type_file, + { + ff_cap_none, /* waypoints */ + ff_cap_read | ff_cap_write, /* tracks */ + ff_cap_none /* routes */ + }, + ggv_log_rd_init, + ggv_log_wr_init, + ggv_log_rd_deinit, + ggv_log_wr_deinit, + ggv_log_read, + ggv_log_write, + NULL, + ggv_log_args, + CET_CHARSET_ASCII, 1 +}; +/**************************************************************************/ diff --git a/globals.c b/globals.c index f51201caa..3891a45e7 100644 --- a/globals.c +++ b/globals.c @@ -28,3 +28,4 @@ const char gpsbabel_version[] = VERSION; time_t gpsbabel_now; /* gpsbabel startup-time; initialized in main.c with time() */ time_t gpsbabel_time; /* gpsbabel startup-time; initialized in main.c with current_time(), ! ZERO within testo ! */ +posn_status tracking_status; diff --git a/google.c b/google.c index 3c126ff62..0496d6422 100644 --- a/google.c +++ b/google.c @@ -22,7 +22,8 @@ static char *encoded_points = NULL; static char *encoded_levels = NULL; static char *script = NULL; -static route_head *routehead; +static route_head **routehead; +static int *routecount; static short_handle desc_handle; static int serial = 0; @@ -56,8 +57,11 @@ xg_tag_mapping google_map[] = { { goog_segment_s, cb_start, "/page/directions/segments/segment" }, { goog_segment, cb_cdata, "/page/directions/segments/segment" }, { goog_td_s, cb_start, "/div/table/tr/td" }, + { goog_td_s, cb_start, "/div/div/table/tr/td" }, { goog_td_b, cb_cdata, "/div/table/tr/td/b" }, + { goog_td_b, cb_cdata, "/div/div/table/tr/td/b" }, { goog_td_e, cb_end, "/div/table/tr/td" }, + { goog_td_e, cb_end, "/div/div/table/tr/td" }, { NULL, 0, NULL } }; @@ -108,6 +112,7 @@ void goog_levels( const char *args, const char **unused ) static char goog_segname[7]; static char *goog_realname = NULL; +static int goog_segroute = 0; /* * The segments contain an index into the points array. We use that @@ -129,7 +134,7 @@ void goog_segment( const char *args, const char **unused ) { waypoint *wpt_tmp; - wpt_tmp = route_find_waypt_by_name( routehead, goog_segname); + wpt_tmp = route_find_waypt_by_name( routehead[goog_segroute], goog_segname); if (wpt_tmp) { xfree(wpt_tmp->shortname); wpt_tmp->shortname = mkshort(desc_handle,args); @@ -141,15 +146,29 @@ void goog_td_s( const char *args, const char **attrv ) { const char **avp = &attrv[0]; int isdesc = 0; + int isseg = 0; while (*avp) { if ( 0 == strcmp(avp[0], "class" )) { isdesc = !strcmp(avp[1], "desc" ); + isseg = !strcmp(avp[1], "dirsegtext" ); } else if ( isdesc && (0 == strcmp( avp[0], "id" ))) { + goog_segroute = 0; snprintf( goog_segname, sizeof(goog_segname), "\\%5.5x", atoi(avp[1] + 6 )); } + else if ( isseg && (0 == strcmp( avp[0], "id" ))) { + if ( strchr(strchr(avp[1],'_')+1,'_')) { + goog_segroute = atoi(strchr(avp[1],'_')+1); + } + else { + goog_segroute = 0; + } + snprintf( goog_segname, sizeof(goog_segname), + "\\%5.5x", + atoi(strrchr( avp[1],'_') + 1 )+routecount[goog_segroute]); + } avp += 2; } } @@ -209,9 +228,10 @@ void goog_poly_e( const char *args, const char **unused ) long level2 = -9999; char *str = encoded_points; char *lstr = encoded_levels; - - routehead = route_head_alloc(); - route_add_head(routehead); + + routehead[goog_segroute] = route_head_alloc(); + route_add_head(routehead[goog_segroute]); + routecount[goog_segroute] = serial; while ( str && *str ) { @@ -241,7 +261,7 @@ void goog_poly_e( const char *args, const char **unused ) wpt_tmp->route_priority=level; wpt_tmp->shortname = (char *) xmalloc(7); sprintf( wpt_tmp->shortname, "\\%5.5x", serial++ ); - route_add_wpt(routehead, wpt_tmp); + route_add_wpt(routehead[goog_segroute], wpt_tmp); } } @@ -259,7 +279,13 @@ google_rd_init(const char *fname) static void google_read(void) { + routehead = (route_head **)xmalloc(sizeof(route_head *)); + routecount = (int *)xmalloc(sizeof(int)); + goog_segroute = 0; xml_read(); + xfree( routehead ); + xfree( routecount ); + if ( encoded_points ) { xfree( encoded_points ); @@ -278,6 +304,9 @@ google_read(void) char *end = NULL; if ( xml && (!dict || (xml < dict ))) { + routehead = (route_head **)xmalloc(sizeof(route_head *)); + routecount = (int *)xmalloc(sizeof(int)); + goog_segroute = 0; xml++; end = strchr( xml+1, '\'' ); if ( end ) { @@ -298,53 +327,193 @@ google_read(void) } } else if ( dict ) { + char qc = '\''; + int ofs = 9; + int panelofs = 8; + int count = 0; + char *tmp = NULL; + char *start = NULL; + char *panel = strstr( dict, "panel: '" ); encoded_points = strstr( dict, "points: '" ); encoded_levels = strstr( dict, "levels: '" ); + if ( !encoded_points ) { + ofs = 10; + qc = '"'; + encoded_points = strstr( dict, "\"points\":\"" ); + encoded_levels = strstr( dict, "\"levels\":\"" ); + if ( !encoded_points ) { + encoded_points = strstr(dict, "points:\"" ); + encoded_levels = strstr(dict, "levels:\"" ); + ofs = 8; + } + } + + if ( !panel ) { + panel = strstr( dict, "panel:\""); + panelofs = 7; + } - if ( encoded_points && encoded_levels ) { - encoded_points += 9; - encoded_levels += 9; - end = strchr( encoded_points, '\'' ); - if ( end ) { - *end = '\0'; - end = encoded_points; - while ( (end = strstr(end, "\\\\" ))) { - memmove( end, end+1, strlen(end)+1 ); - end++; + tmp = panel; + while ( tmp ) { + if ( qc == '"' ) { + char *tmp1 = strstr( tmp, "\"points\":\"" ); + if ( !tmp1 ) { + tmp1 = strstr( tmp, "points:\"" ); } - end = strchr( encoded_levels, '\'' ); + tmp = tmp1; + } + else { + tmp = strstr( tmp, "points: '" ); + } + count++; + if ( tmp ) { + tmp++; + } + } + routehead = (route_head **)xmalloc(sizeof(route_head *)*count); + routecount = (int *)xmalloc(sizeof(int)*count); + goog_segroute = 0; + + do { + + if ( encoded_points && encoded_levels ) { + encoded_points += ofs; + encoded_levels += ofs; + end = strchr( encoded_points, qc ); if ( end ) { - *end = '\0'; - end = encoded_levels; - while ( (end = strstr(end, "\\\\" ))) { - memmove( end, end+1, strlen(end)+1 ); + *end = '\0'; + end = encoded_points; + while ( (end = strstr(end, "\\\\" ))) { + memmove( end, end+1, strlen(end)+1 ); end++; } - goog_poly_e( NULL, NULL ); - } - } - } + end = strchr( encoded_levels, qc ); + if ( end ) { + start = end; + *end = '\0'; + end = encoded_levels; + while ( (end = strstr(end, "\\\\" ))) { + memmove( end, end+1, strlen(end)+1 ); + end++; + } + goog_poly_e( NULL, NULL ); + + goog_segroute++; + start++; + { + encoded_points = strstr( start, "points: '" ); + encoded_levels = strstr( start, "levels: '" ); + } + if ( !encoded_points ) { + encoded_points = strstr( start, "\"points\":\"" ); + encoded_levels = strstr( start, "\"levels\":\"" ); + } + if ( !encoded_points ) { + encoded_points = strstr( start, "points:\"" ); + encoded_levels = strstr( start, "levels:\"" ); + } + } + } + } + } while ( start && encoded_points && encoded_levels ); if ( panel ) { - panel += 8; + panel += panelofs; end = strstr( panel, "/table>
"); - end = panel; - while ( (end = strstr( end, "\\\"" ))) { - memmove( end, end+1, strlen(end)+1 ); + if ( !end ) { + end = strstr( panel, "/table>
"); + } + if ( !end ) { + end = strstr( panel, "/div>
"); } - end = panel; - while ( (end = strstr( end, "\\'" ))) { - memmove( end, end+1, strlen(end)+1 ); + } + + if ( end ) { + char *to = panel; + char *from = panel; + while ( *from ) { + if ( !strncmp( from, "\\\"", 2 )) { + *to++ = '"'; + from += 2; + if ( *(to-2) != '=' ) { + *to++ = ' '; + } + } + else if ( !strncmp( from, "\\042", 4)) { + *to++ = '"'; + from += 4; + + if ( *(to-2) != '=' ) { + *to++ = ' '; + } + } + else if ( !strncmp( from, "\\u0026utm", 9)) { + strcpy( to, "&utm" ); + to += 8; + from += 9; + } + else if ( !strncmp( from, "\\u0026", 6 )) { + *to++='&'; + from += 6; + } + else if ( !strncmp( from, "\\u003c", 6 )) { + *to++='<'; + from += 6; + } + else if ( !strncmp( from, "\\u003e", 6 )) { + *to++='>'; + from += 6; + } + else if ( !strncmp( from, "\\'", 2)) { + *to++ = '\''; + from += 2; + } + else if ( !strncmp( from, " nowrap ", 8)) { + *to++ = ' '; + from += 8; + } + else if ( !strncmp( from, "tr style=\\\"display:none", 23 )) { + if ( strcmp( to-5, "/tr><" )) { + /* broken 6-26-07 missing that apparently doesn't bother browsers */ + strcpy(to, "/tr><" ); + to += 5; + } + *to++ = *from++; + } + else { + *to++ = *from++; + } + } + *to = '\0'; + +#if 0 + { + FILE *foo = fopen( "foo.xml", "w" ); + fwrite( panel, sizeof(char), strlen(panel), foo ); + fclose( foo ); } +#endif + xml_deinit(); xml_init( NULL, google_map, NULL ); + xml_readprefixstring( "" ); xml_readstring( panel ); } } } xfree( script ); + xfree( routehead ); + xfree( routecount ); script = NULL; } diff --git a/gpilots.c b/gpilots.c index b59e2a409..f7ada83b3 100644 --- a/gpilots.c +++ b/gpilots.c @@ -21,8 +21,7 @@ #include "defs.h" #if PDBFMTS_ENABLED -#include "coldsync/palm.h" -#include "coldsync/pdb.h" +#include "pdbfile.h" #include "garmin_tables.h" #define MYNAME "GPilotS" @@ -151,12 +150,9 @@ struct record }; -static FILE *file_in; -static FILE *file_out; +static pdbfile *file_in, *file_out; static const char *out_fname; -static struct pdb *opdb; -static struct pdb_record *opdb_rec; - +static int ct = 0; static char *dbname = NULL; static @@ -168,13 +164,13 @@ arglist_t my_args[] = { static void rd_init(const char *fname) { - file_in = xfopen(fname, "rb", MYNAME); + file_in = pdb_open(fname, MYNAME); } static void rd_deinit(void) { - fclose(file_in); + pdb_close(file_in); if ( dbname ) { xfree(dbname); dbname = NULL; @@ -184,14 +180,14 @@ rd_deinit(void) static void wr_init(const char *fname) { - file_out = xfopen(fname, "wb", MYNAME); + file_out = pdb_create(fname, MYNAME); out_fname = fname; } static void wr_deinit(void) { - fclose(file_out); + pdb_close(file_out); if ( dbname ) { xfree(dbname); dbname = NULL; @@ -202,19 +198,14 @@ static void data_read(void) { struct record *rec; - struct pdb *pdb; - struct pdb_record *pdb_rec; + pdbrec_t *pdb_rec; route_head *track_head = NULL; - if (NULL == (pdb = pdb_Read(fileno(file_in)))) { - fatal(MYNAME ": pdb_Read failed\n"); - } - - if (pdb->creator != MYCREATOR) { + if (file_in->creator != MYCREATOR) { fatal(MYNAME ": Not a %s file.\n", MYNAME); } - switch(pdb->type) { + switch(file_in->type) { case MYWPT: /* blah */ break; @@ -222,10 +213,10 @@ data_read(void) /* blah */ break; default: - fatal(MYNAME ": Unknown file type 0x%x\n", (int) pdb->type); + fatal(MYNAME ": Unknown file type 0x%x\n", (int) file_in->type); } - for(pdb_rec = pdb->rec_index.rec; pdb_rec; pdb_rec=pdb_rec->next) { + for(pdb_rec = file_in->rec_list; pdb_rec; pdb_rec=pdb_rec->next) { waypoint *wpt_tmp; Custom_Trk_Point_Type *tp_cust; Compact_Trk_Point_Type *tp_comp; @@ -275,9 +266,9 @@ data_read(void) fi.i = le_read32(&rec->wpt.d108.alt); wpt_tmp->altitude = fi.f; fi.i = le_read32(&rec->wpt.d108.dpth); - wpt_tmp->depth = fi.f; + WAYPT_SET(wpt_tmp, depth, fi.f); fi.i = le_read32(&rec->wpt.d108.dist); - wpt_tmp->proximity = fi.f; + WAYPT_SET(wpt_tmp, proximity, fi.f); wpt_tmp->wpt_flags.icon_descr_is_dynamic = 0; wpt_tmp->icon_descr = gt_find_desc_from_icon_number((rec->wpt.d108.smbl[1] << 8) + rec->wpt.d108.smbl[0], PCX, NULL); waypt_add(wpt_tmp); @@ -378,7 +369,6 @@ data_read(void) } } - free_pdb(pdb); } @@ -391,7 +381,6 @@ static void my_write_wpt(const waypoint *wpt) { struct record *rec; - static int ct; char *vdata; int lat, lon; @@ -406,45 +395,31 @@ my_write_wpt(const waypoint *wpt) le_write32(&rec->wpt.d103.lat, lat); le_write32(&rec->wpt.d103.lon, lon); - opdb_rec = new_Record(0, 0, ct++, (uword) (vdata - (char *) rec), (const ubyte *) rec); - - if (opdb_rec == NULL) { - fatal(MYNAME ": libpdb couldn't create record\n"); - } - - if (pdb_AppendRecord(opdb, opdb_rec)) { - fatal(MYNAME ": libpdb couldn't append record\n"); - } + pdb_write_rec(file_out, 0, 0, ct++, rec, (char *)vdata - (char *)rec); xfree(rec); } static void data_write(void) { - if (NULL == (opdb = new_pdb())) { - fatal (MYNAME ": new_pdb failed\n"); - } - if ( dbname ) { - strncpy( opdb->name, dbname, PDB_DBNAMELEN ); + strncpy( file_out->name, dbname, PDB_DBNAMELEN ); } else { - strncpy(opdb->name, out_fname, PDB_DBNAMELEN); + strncpy(file_out->name, out_fname, PDB_DBNAMELEN); } /* * Populate header. */ - opdb->name[PDB_DBNAMELEN-1] = 0; - opdb->attributes = PDB_ATTR_BACKUP; - opdb->ctime = opdb->mtime = current_time() + 2082844800U; + file_out->name[PDB_DBNAMELEN-1] = 0; + file_out->attr = PDB_FLAG_BACKUP; + file_out->ctime = file_out->mtime = current_time() + 2082844800U; - opdb->type = MYWPT; - opdb->creator = MYCREATOR; - opdb->version = 1; + file_out->type = MYWPT; + file_out->creator = MYCREATOR; + file_out->version = 1; waypt_disp_all(my_write_wpt); - - pdb_Write(opdb, fileno(file_out)); } diff --git a/gpsbabel.html b/gpsbabel.html index 83807aef4..2550b9dad 100644 --- a/gpsbabel.html +++ b/gpsbabel.html @@ -1,9 +1,9 @@ -GPSBabel Documentation

GPSBabel Documentation


Table of Contents

Introduction
The Problem: Too many incompatible formats
The Solution
1. Getting it and Building it
2. Usage
Invocation
Suboptions
Advanced Usage
Route and Track Modes
Working with predefined options
Realtime tracking
Batch mode (command files)
3. The Formats
? Character Separated Values (xcsv)
Alan Map500 tracklogs (.trl) (alantrl)
Alan Map500 waypoints and routes (.wpr) (alanwpr)
All database fields on one tab-separated line (tabsep)
Brauniger IQ Series Barograph Download (baroiq)
Cambridge/Winpilot glider software (cambridge)
CarteSurTable data file (cst)
Cetus for Palm/OS (cetus)
CoastalExplorer XML (coastexp)
Comma separated values (csv)
CompeGPS data files (.wpt/.trk/.rte) (compegps)
CoPilot Flight Planner for Palm/OS (copilot)
cotoGPS for Palm/OS (coto)
Custom "Everything" Style (custom)
Dell Axim Navigation System (.gpb) file format (axim_gpb)
DeLorme .an1 (drawing) file (an1)
DeLorme GPL (gpl)
DeLorme Street Atlas Plus (saplus)
DeLorme Street Atlas Route (saroute)
DeLorme XMap HH Native .WPT (xmap)
DeLorme XMap/SAHH 2006 Native .TXT (xmap2006)
DeLorme XMat HH Street Atlas USA .WPT (PPC) (xmapwpt)
EasyGPS binary format (easygps)
FAI/IGC Flight Recorder Data Format (igc)
Franson GPSGate Simulation (gpssim)
Fugawi (fugawi)
Garmin 301 Custom position and heartrate (garmin301)
Garmin Logbook XML (glogbook)
Garmin MapSource - gdb (gdb)
Garmin MapSource - mps (mapsource)
Garmin MapSource - txt (tab delimited) (garmin_txt)
Garmin PCX5 (pcx)
Garmin POI database (garmin_poi)
Garmin serial/USB protocol (garmin)
Garmin Training Centerxml (gtrnctr)
Geocaching.com .loc (geo)
GeocachingDB for Palm/OS (gcdb)
GEOnet Names Server (GNS) (geonet)
GeoNiche .pdb (geoniche)
Google Earth (Keyhole) Markup Language (kml)
Google Maps XML (google)
GpilotS (gpilots)
GPS TrackMaker (gtm)
GPSBabel arc filter file (arc)
GpsDrive Format (gpsdrive)
GpsDrive Format for Tracks (gpsdrivetrack)
GPSman (gpsman)
GPSPilot Tracker for Palm/OS (gpspilot)
gpsutil (gpsutil)
GPX XML (gpx)
HikeTech (hiketech)
Holux (gm-100) .wpo Format (holux)
HSA Endeavour Navigator export File (hsandv)
HTML Output (html)
IGN Rando track files (ignrando)
Kartex 5 Track File (ktf2)
Kartex 5 Waypoint File (kwf2)
Kompass (DAV) Track (.tk) (kompass_tk)
Kompass (DAV) Waypoints (.wp) (kompass_wp)
KuDaTa PsiTrex text (psitrex)
Lowrance USR (lowranceusr)
Magellan Explorist Geocaching (maggeo)
Magellan Mapsend (mapsend)
Magellan NAV Companion for Palm/OS (magnav)
Magellan SD files (as for eXplorist) (magellanx)
Magellan SD files (as for Meridian) (magellan)
Magellan serial protocol (magellan)
Map&Guide 'TourExchangeFormat' XML (tef)
Map&Guide to Palm/OS exported files (.pdb) (mag_pdb)
Mapopolis.com Mapconverter CSV (mapconverter)
MapTech Exchange Format (mxf)
Microsoft AutoRoute 2002 (pin/route reader) (msroute)
Microsoft Streets and Trips (pin/route reader) (msroute)
Microsoft Streets and Trips 2002-2006 (s_and_t)
Motorrad Routenplaner (Map&Guide) .bcr files (bcr)
MS PocketStreets 2002 Pushpin (psp)
National Geographic Topo .tpg (waypoints) (tpg)
National Geographic Topo 2.x .tpo (tpo2)
National Geographic Topo 3.x/4.x .tpo (tpo3)
Navicache.com XML (navicache)
Navigon Mobile Navigator .rte files (nmn4)
Navitrak DNA marker format (dna)
NetStumbler Summary File (text) (netstumbler)
NIMA/GNIS Geographic Names File (nima)
NMEA 0183 sentences (nmea)
OziExplorer (ozi)
PalmDoc Output (palmdoc)
PathAway Database for Palm/OS (pathaway)
Quovadis (quovadis)
Raymarine Waypoint File (.rwf) (raymarine)
See You flight analysis data (cup)
Sportsim track files (part of zipped .ssz files) (sportsim)
Suunto Trek Manager (STM) .sdf files (stmsdf)
Suunto Trek Manager (STM) WaypointPlus files (stmwpp)
Tab delimited fields useful for OpenOffice, Ploticus etc. (openoffice)
Textual Output (text)
TomTom POI file (tomtom)
TopoMapPro Places File (tmpro)
TrackLogs digital mapping (.trl) (dmtlog)
U.S. Census Bureau Tiger Mapping Service (tiger)
Universal csv with field structure in first line (unicsv)
Vcard Output (for iPod) (vcard)
Vito Navigator II tracks (vitosmt)
WiFiFoFum 2.0 for PocketPC XML (wfff)
Wintec WBT-100/200 Binary file format (wbt-bin)
Wintec WBT-100/200 GPS Download (wbt)
Yahoo Geocode API data (yahoo)
4. Data Filters
Include Only Points Inside Polygon (polygon)
Include Only Points Within Distance of Arc (arc)
Include Only Points Within Radius (radius)
Interpolate between trackpoints (interpolate)
Manipulate track lists (track)
Rearrange waypoints by resorting (sort)
Remove all waypoints, tracks, or routes (nuketypes)
Remove Duplicates (duplicate)
Remove Points Within Distance (position)
Remove unreliable points with high hdop or vdop (discard)
Reverse stops within routes (reverse)
Save and restore waypoint lists (stack)
Simplify routes (simplify)
Transform waypoints into a route, tracks into routes, ... (transform)
A. Supported Datums
B. Garmin Icons
C. GPSBabel XCSV Style Files
Introduction
Style file overview
Internal Constants
Global Properties of the File
GPSBabel Behavior Directives
Defining the Layout of the File
Defining Fields Within the File
Examples
Miscellaneous Notes

List of Tables

3.1. Grid values for garmin_txt

List of Examples

3.1. Command showing garmin_txt output with all options
3.2. Sample BCR command with all options
3.3. Command showing conversion of a Wintec binary file to GPX
3.4. Command showing WBT-200 download and erase over Bluetooth on Mac OS X
4.1. Using the polygon filter
4.2. Using the polygon and arc filters to find points in or nearly in a +GPSBabel Documentation

GPSBabel Documentation


Table of Contents

Introduction
The Problem: Too many incompatible GPS file formats
The Solution
1. Getting it and Building it
2. Usage
Invocation
Suboptions
Advanced Usage
Route and Track Modes
Working with predefined options
Realtime tracking
Batch mode (command files)
3. The Formats
? Character Separated Values (xcsv)
Alan Map500 tracklogs (.trl) (alantrl)
Alan Map500 waypoints and routes (.wpr) (alanwpr)
All database fields on one tab-separated line (tabsep)
Brauniger IQ Series Barograph Download (baroiq)
Cambridge/Winpilot glider software (cambridge)
CarteSurTable data file (cst)
Cetus for Palm/OS (cetus)
CoastalExplorer XML (coastexp)
Comma separated values (csv)
CompeGPS data files (.wpt/.trk/.rte) (compegps)
CoPilot Flight Planner for Palm/OS (copilot)
cotoGPS for Palm/OS (coto)
Custom "Everything" Style (custom)
Dell Axim Navigation System (.gpb) file format (axim_gpb)
DeLorme .an1 (drawing) file (an1)
DeLorme GPL (gpl)
DeLorme Street Atlas Plus (saplus)
DeLorme Street Atlas Route (saroute)
DeLorme XMap HH Native .WPT (xmap)
DeLorme XMap/SAHH 2006 Native .TXT (xmap2006)
DeLorme XMat HH Street Atlas USA .WPT (PPC) (xmapwpt)
EasyGPS binary format (easygps)
FAI/IGC Flight Recorder Data Format (igc)
Franson GPSGate Simulation (gpssim)
Fugawi (fugawi)
G7ToWin data files (.g7t) (g7towin)
Garmin 301 Custom position and heartrate (garmin301)
Garmin Logbook XML (glogbook)
Garmin MapSource - gdb (gdb)
Garmin MapSource - mps (mapsource)
Garmin MapSource - txt (tab delimited) (garmin_txt)
Garmin PCX5 (pcx)
Garmin POI database (garmin_poi)
Garmin Points of Interest (.gpi) (garmin_gpi)
Garmin serial/USB protocol (garmin)
Garmin Training Centerxml (gtrnctr)
Geocaching.com .loc (geo)
GeocachingDB for Palm/OS (gcdb)
Geogrid Viewer tracklogs (.log) (ggv_log)
GEOnet Names Server (GNS) (geonet)
GeoNiche .pdb (geoniche)
Google Earth (Keyhole) Markup Language (kml)
Google Maps XML (google)
GpilotS (gpilots)
GPS TrackMaker (gtm)
GPSBabel arc filter file (arc)
GpsDrive Format (gpsdrive)
GpsDrive Format for Tracks (gpsdrivetrack)
GPSman (gpsman)
GPSPilot Tracker for Palm/OS (gpspilot)
gpsutil (gpsutil)
GPX XML (gpx)
HikeTech (hiketech)
Holux (gm-100) .wpo Format (holux)
HSA Endeavour Navigator export File (hsandv)
HTML Output (html)
IGN Rando track files (ignrando)
Kartex 5 Track File (ktf2)
Kartex 5 Waypoint File (kwf2)
Kompass (DAV) Track (.tk) (kompass_tk)
Kompass (DAV) Waypoints (.wp) (kompass_wp)
KuDaTa PsiTrex text (psitrex)
Lowrance USR (lowranceusr)
Magellan Explorist Geocaching (maggeo)
Magellan Mapsend (mapsend)
Magellan NAV Companion for Palm/OS (magnav)
Magellan SD files (as for eXplorist) (magellanx)
Magellan SD files (as for Meridian) (magellan)
Magellan serial protocol (magellan)
Map&Guide 'TourExchangeFormat' XML (tef)
Map&Guide to Palm/OS exported files (.pdb) (mag_pdb)
Mapopolis.com Mapconverter CSV (mapconverter)
MapTech Exchange Format (mxf)
Microsoft AutoRoute 2002 (pin/route reader) (msroute)
Microsoft Streets and Trips (pin/route reader) (msroute)
Microsoft Streets and Trips 2002-2006 (s_and_t)
Motorrad Routenplaner (Map&Guide) .bcr files (bcr)
MS PocketStreets 2002 Pushpin (psp)
National Geographic Topo .tpg (waypoints) (tpg)
National Geographic Topo 2.x .tpo (tpo2)
National Geographic Topo 3.x/4.x .tpo (tpo3)
Navicache.com XML (navicache)
Navigon Mobile Navigator .rte files (nmn4)
Navitrak DNA marker format (dna)
NetStumbler Summary File (text) (netstumbler)
NIMA/GNIS Geographic Names File (nima)
NMEA 0183 sentences (nmea)
OziExplorer (ozi)
PalmDoc Output (palmdoc)
PathAway Database for Palm/OS (pathaway)
Quovadis (quovadis)
Raymarine Waypoint File (.rwf) (raymarine)
See You flight analysis data (cup)
Sportsim track files (part of zipped .ssz files) (sportsim)
Suunto Trek Manager (STM) .sdf files (stmsdf)
Suunto Trek Manager (STM) WaypointPlus files (stmwpp)
Tab delimited fields useful for OpenOffice, Ploticus etc. (openoffice)
Textual Output (text)
TomTom Itineraries (.itn) (tomtom_itn)
TomTom POI file (.asc) (tomtom_asc)
TomTom POI file (.ov2) (tomtom)
TopoMapPro Places File (tmpro)
TrackLogs digital mapping (.trl) (dmtlog)
U.S. Census Bureau Tiger Mapping Service (tiger)
Universal csv with field structure in first line (unicsv)
Vcard Output (for iPod) (vcard)
Vito Navigator II tracks (vitosmt)
Vito SmartMap tracks (.vtt) (vitovtt)
WiFiFoFum 2.0 for PocketPC XML (wfff)
Wintec WBT-100/200 Binary File Format (wbt-bin)
Wintec WBT-100/200 GPS Download (wbt)
Wintec WBT-201/G-Rays 2 Binary File Format (wbt-tk1)
Yahoo Geocode API data (yahoo)
4. Data Filters
Include Only Points Inside Polygon (polygon)
Include Only Points Within Distance of Arc (arc)
Include Only Points Within Radius (radius)
Interpolate between trackpoints (interpolate)
Manipulate track lists (track)
Rearrange waypoints by resorting (sort)
Remove all waypoints, tracks, or routes (nuketypes)
Remove Duplicates (duplicate)
Remove Points Within Distance (position)
Remove unreliable points with high hdop or vdop (discard)
Reverse stops within routes (reverse)
Save and restore waypoint lists (stack)
Simplify routes (simplify)
Transform waypoints into a route, tracks into routes, ... (transform)
A. Supported Datums
B. Garmin Icons
C. GPSBabel XCSV Style Files
Introduction
Style file overview
Internal Constants
Global Properties of the File
GPSBabel Behavior Directives
Defining the Layout of the File
Defining Fields Within the File
Examples
Miscellaneous Notes
Glossary

Introduction

The Problem: Too many incompatible formats

There are simply too many gratuitously different file formats +geocaches

4.13. Using the position filter to suppress close points
4.14. Using the discard filter
4.15. Converting a track to a sequence of waypoints
4.16. Converting a pile of waypoints to a GPX route
4.17. Converting a pile of waypoints to a GPX track
4.18. Convert a GPX track to GPX waypoints, tossing the original track

Introduction

The Problem: Too many incompatible GPS file formats

There are simply too many gratuitously different file formats to hold waypoint, track, and route information in various programs used by computers and GPS receivers. GPX defines a @@ -53,7 +53,7 @@ need to 'apt-get install libusb-dev'.

There are additional flags that can be passed to configure to customize your build of GPSBabel.

./configure --help

-lists all the supported options, but additionally we have: +lists all the supported options, but additionally we have:

--disable-shapefile Excludes the shapefile support.

--disable-pdb Excludes the Palm database support and all formats that rely on it. @@ -90,11 +90,10 @@ name of a file to be read or written.

To use this program, just tell it what you're reading, where to read it from, what you're writing, and what to write it to. For - example:

gpsbabel -i geo -f /tmp/geocaching.loc -o gpx -F /tmp/geocaching.gpx

tells it to read the file "/tmp/geocaching.loc" in geocaching.com - format and create a new file in GPX format.

This command will read from a Magellan unit attached + example:

gpsbabel -i geo -f /tmp/geocaching.loc -o gpx -F /tmp/geocaching.gpx

tells it to read the file /tmp/geocaching.loc in geocaching.com + format and create a new file /tmp/geocaching.gpx in GPX format. It's important to note that the names have nothign to do with the formats actually used.

This command will read from a Magellan unit attached to the first serial port on a Linux system (device names will - vary on other OSes) and write them as a geocaching loc file. - The second command does the same on Microsoft Windows.

gpsbabel -i magellan -f /dev/ttyS0 -o geo -F mag.loc

gpsbabel -i magellan -f com1 -o geo -F mag.loc

Optionally, you may specify "-s" in any command line. This + vary on other OSes) and write them as a geocaching loc file.

gpsbabel -i magellan -f /dev/ttyS0 -o geo -F mag.loc

This second command does the same on Microsoft Windows.

gpsbabel -i magellan -f com1 -o geo -F mag.loc

Optionally, you may specify -s in any command line. This causes the program to ignore any "short" names that may be present in the source data format and synthesize one from the long name. This is particularly useful if you're writing to @@ -107,7 +106,7 @@ name of a file to be read or written. like this useful.

gpsbabel -s -i geo -f geocaching.loc -o magellan -F /dev/ttyS0

gpsbabel -s -i geo -f geocaching.loc -o magellan -F com1

Suboptions

Many of the available format options in GPSBabel can themselves take options. While we try to make all the formats do the most - sensible thing possible without any extra options, this allows + sensible thing possible without any extra options; this allows great power and flexibility in the operation of the program.

Suboptions are comma separated and immediately follow the option @@ -139,7 +138,7 @@ merged data to multiple destinations. output side you can do this with the option -c <character set>. You can get a complete list of supported character sets with "gpsbabel -l". To change - the character set on both sides you should do this:

gpsbabel -i xcsv,style=foo.style -c latin1 -f foo -o xcsv,style=bar.style -c ms-ansi -F bar

Note, that some formats has a fixed character set and ignore this option.

Route and Track Modes

Most formats supported by GPSBabel will make a reasonable attempt to work + the character set on both sides you should do this:

gpsbabel -i xcsv,style=foo.style -c latin1 -f foo -o xcsv,style=bar.style -c ms-ansi -F bar

Note, that some formats have a fixed character set and ignore this option.

Route and Track Modes

Most formats supported by GPSBabel will make a reasonable attempt to work transparently with waypoints, tracks, and routes. Some formats, like garmin and magellan require the -t flag to work with tracks and -r to work with @@ -157,7 +156,7 @@ merged data to multiple destinations. retained the 30 most mathematically significant turnpoints but that may not really be the route you had in mind.

Tracks and routes will sometimes be converted to a - list of waypoints when necessary, f.i. when writing into one + list of waypoints when necessary, One example is when writing into one of the CSV formats. The inverse operation is not supported right now, so reading the converted track back from CSV will always result in a list of waypoints, not the original track. @@ -203,8 +202,9 @@ merged data to multiple destinations. Introduced in GPSBabel 1.3.1, we now have an experimental feature for realtime tracking via the new -T option. This reads position reports from selected formats and writes an output file when a position report is received.

As of this writing, Garmin's PVT protocol and NMEA are supported - inputs and KML is supported on output. Additional formats - may be added by interested parties later. + inputs. KML, NMEA, and the variou XCSV formats are supported on + output. Additional formats may be added by interested parties + later.

gpsbabel -T -i garmin -f usb: -o kml -F xxx.kml

Will read the USB-connected Garmin and rewrite 'xxx.kml' atomically, suitable for a self-refreshing network link in Google Earth. @@ -220,7 +220,7 @@ merged data to multiple destinations. by placing the input and filtering directives in a file called 'all_my_files'.

gpsbabel -b all_my_files -o gdb -F all_my_tracks.gdb

'all_my_files' could look like this: -

-i gpx
-f saxony_in_summer_2004.gpx -f austria_2005.gpx
-i gdb
-f croatia_2006.gdb
-x nuketypes,waypoints,routes
-x track,pack,split,title="LOG # %Y%m%d"

Chapter 3. The Formats

Table of Contents

? Character Separated Values (xcsv)
Alan Map500 tracklogs (.trl) (alantrl)
Alan Map500 waypoints and routes (.wpr) (alanwpr)
All database fields on one tab-separated line (tabsep)
Brauniger IQ Series Barograph Download (baroiq)
Cambridge/Winpilot glider software (cambridge)
CarteSurTable data file (cst)
Cetus for Palm/OS (cetus)
CoastalExplorer XML (coastexp)
Comma separated values (csv)
CompeGPS data files (.wpt/.trk/.rte) (compegps)
CoPilot Flight Planner for Palm/OS (copilot)
cotoGPS for Palm/OS (coto)
Custom "Everything" Style (custom)
Dell Axim Navigation System (.gpb) file format (axim_gpb)
DeLorme .an1 (drawing) file (an1)
DeLorme GPL (gpl)
DeLorme Street Atlas Plus (saplus)
DeLorme Street Atlas Route (saroute)
DeLorme XMap HH Native .WPT (xmap)
DeLorme XMap/SAHH 2006 Native .TXT (xmap2006)
DeLorme XMat HH Street Atlas USA .WPT (PPC) (xmapwpt)
EasyGPS binary format (easygps)
FAI/IGC Flight Recorder Data Format (igc)
Franson GPSGate Simulation (gpssim)
Fugawi (fugawi)
Garmin 301 Custom position and heartrate (garmin301)
Garmin Logbook XML (glogbook)
Garmin MapSource - gdb (gdb)
Garmin MapSource - mps (mapsource)
Garmin MapSource - txt (tab delimited) (garmin_txt)
Garmin PCX5 (pcx)
Garmin POI database (garmin_poi)
Garmin serial/USB protocol (garmin)
Garmin Training Centerxml (gtrnctr)
Geocaching.com .loc (geo)
GeocachingDB for Palm/OS (gcdb)
GEOnet Names Server (GNS) (geonet)
GeoNiche .pdb (geoniche)
Google Earth (Keyhole) Markup Language (kml)
Google Maps XML (google)
GpilotS (gpilots)
GPS TrackMaker (gtm)
GPSBabel arc filter file (arc)
GpsDrive Format (gpsdrive)
GpsDrive Format for Tracks (gpsdrivetrack)
GPSman (gpsman)
GPSPilot Tracker for Palm/OS (gpspilot)
gpsutil (gpsutil)
GPX XML (gpx)
HikeTech (hiketech)
Holux (gm-100) .wpo Format (holux)
HSA Endeavour Navigator export File (hsandv)
HTML Output (html)
IGN Rando track files (ignrando)
Kartex 5 Track File (ktf2)
Kartex 5 Waypoint File (kwf2)
Kompass (DAV) Track (.tk) (kompass_tk)
Kompass (DAV) Waypoints (.wp) (kompass_wp)
KuDaTa PsiTrex text (psitrex)
Lowrance USR (lowranceusr)
Magellan Explorist Geocaching (maggeo)
Magellan Mapsend (mapsend)
Magellan NAV Companion for Palm/OS (magnav)
Magellan SD files (as for eXplorist) (magellanx)
Magellan SD files (as for Meridian) (magellan)
Magellan serial protocol (magellan)
Map&Guide 'TourExchangeFormat' XML (tef)
Map&Guide to Palm/OS exported files (.pdb) (mag_pdb)
Mapopolis.com Mapconverter CSV (mapconverter)
MapTech Exchange Format (mxf)
Microsoft AutoRoute 2002 (pin/route reader) (msroute)
Microsoft Streets and Trips (pin/route reader) (msroute)
Microsoft Streets and Trips 2002-2006 (s_and_t)
Motorrad Routenplaner (Map&Guide) .bcr files (bcr)
MS PocketStreets 2002 Pushpin (psp)
National Geographic Topo .tpg (waypoints) (tpg)
National Geographic Topo 2.x .tpo (tpo2)
National Geographic Topo 3.x/4.x .tpo (tpo3)
Navicache.com XML (navicache)
Navigon Mobile Navigator .rte files (nmn4)
Navitrak DNA marker format (dna)
NetStumbler Summary File (text) (netstumbler)
NIMA/GNIS Geographic Names File (nima)
NMEA 0183 sentences (nmea)
OziExplorer (ozi)
PalmDoc Output (palmdoc)
PathAway Database for Palm/OS (pathaway)
Quovadis (quovadis)
Raymarine Waypoint File (.rwf) (raymarine)
See You flight analysis data (cup)
Sportsim track files (part of zipped .ssz files) (sportsim)
Suunto Trek Manager (STM) .sdf files (stmsdf)
Suunto Trek Manager (STM) WaypointPlus files (stmwpp)
Tab delimited fields useful for OpenOffice, Ploticus etc. (openoffice)
Textual Output (text)
TomTom POI file (tomtom)
TopoMapPro Places File (tmpro)
TrackLogs digital mapping (.trl) (dmtlog)
U.S. Census Bureau Tiger Mapping Service (tiger)
Universal csv with field structure in first line (unicsv)
Vcard Output (for iPod) (vcard)
Vito Navigator II tracks (vitosmt)
WiFiFoFum 2.0 for PocketPC XML (wfff)
Wintec WBT-100/200 Binary file format (wbt-bin)
Wintec WBT-100/200 GPS Download (wbt)
Yahoo Geocode API data (yahoo)

? Character Separated Values (xcsv)

+

-i gpx
-f saxony_in_summer_2004.gpx -f austria_2005.gpx
-i gdb
-f croatia_2006.gdb
-x nuketypes,waypoints,routes
-x track,pack,split,title="LOG # %Y%m%d"

Chapter 3. The Formats

Table of Contents

? Character Separated Values (xcsv)
Alan Map500 tracklogs (.trl) (alantrl)
Alan Map500 waypoints and routes (.wpr) (alanwpr)
All database fields on one tab-separated line (tabsep)
Brauniger IQ Series Barograph Download (baroiq)
Cambridge/Winpilot glider software (cambridge)
CarteSurTable data file (cst)
Cetus for Palm/OS (cetus)
CoastalExplorer XML (coastexp)
Comma separated values (csv)
CompeGPS data files (.wpt/.trk/.rte) (compegps)
CoPilot Flight Planner for Palm/OS (copilot)
cotoGPS for Palm/OS (coto)
Custom "Everything" Style (custom)
Dell Axim Navigation System (.gpb) file format (axim_gpb)
DeLorme .an1 (drawing) file (an1)
DeLorme GPL (gpl)
DeLorme Street Atlas Plus (saplus)
DeLorme Street Atlas Route (saroute)
DeLorme XMap HH Native .WPT (xmap)
DeLorme XMap/SAHH 2006 Native .TXT (xmap2006)
DeLorme XMat HH Street Atlas USA .WPT (PPC) (xmapwpt)
EasyGPS binary format (easygps)
FAI/IGC Flight Recorder Data Format (igc)
Franson GPSGate Simulation (gpssim)
Fugawi (fugawi)
G7ToWin data files (.g7t) (g7towin)
Garmin 301 Custom position and heartrate (garmin301)
Garmin Logbook XML (glogbook)
Garmin MapSource - gdb (gdb)
Garmin MapSource - mps (mapsource)
Garmin MapSource - txt (tab delimited) (garmin_txt)
Garmin PCX5 (pcx)
Garmin POI database (garmin_poi)
Garmin Points of Interest (.gpi) (garmin_gpi)
Garmin serial/USB protocol (garmin)
Garmin Training Centerxml (gtrnctr)
Geocaching.com .loc (geo)
GeocachingDB for Palm/OS (gcdb)
Geogrid Viewer tracklogs (.log) (ggv_log)
GEOnet Names Server (GNS) (geonet)
GeoNiche .pdb (geoniche)
Google Earth (Keyhole) Markup Language (kml)
Google Maps XML (google)
GpilotS (gpilots)
GPS TrackMaker (gtm)
GPSBabel arc filter file (arc)
GpsDrive Format (gpsdrive)
GpsDrive Format for Tracks (gpsdrivetrack)
GPSman (gpsman)
GPSPilot Tracker for Palm/OS (gpspilot)
gpsutil (gpsutil)
GPX XML (gpx)
HikeTech (hiketech)
Holux (gm-100) .wpo Format (holux)
HSA Endeavour Navigator export File (hsandv)
HTML Output (html)
IGN Rando track files (ignrando)
Kartex 5 Track File (ktf2)
Kartex 5 Waypoint File (kwf2)
Kompass (DAV) Track (.tk) (kompass_tk)
Kompass (DAV) Waypoints (.wp) (kompass_wp)
KuDaTa PsiTrex text (psitrex)
Lowrance USR (lowranceusr)
Magellan Explorist Geocaching (maggeo)
Magellan Mapsend (mapsend)
Magellan NAV Companion for Palm/OS (magnav)
Magellan SD files (as for eXplorist) (magellanx)
Magellan SD files (as for Meridian) (magellan)
Magellan serial protocol (magellan)
Map&Guide 'TourExchangeFormat' XML (tef)
Map&Guide to Palm/OS exported files (.pdb) (mag_pdb)
Mapopolis.com Mapconverter CSV (mapconverter)
MapTech Exchange Format (mxf)
Microsoft AutoRoute 2002 (pin/route reader) (msroute)
Microsoft Streets and Trips (pin/route reader) (msroute)
Microsoft Streets and Trips 2002-2006 (s_and_t)
Motorrad Routenplaner (Map&Guide) .bcr files (bcr)
MS PocketStreets 2002 Pushpin (psp)
National Geographic Topo .tpg (waypoints) (tpg)
National Geographic Topo 2.x .tpo (tpo2)
National Geographic Topo 3.x/4.x .tpo (tpo3)
Navicache.com XML (navicache)
Navigon Mobile Navigator .rte files (nmn4)
Navitrak DNA marker format (dna)
NetStumbler Summary File (text) (netstumbler)
NIMA/GNIS Geographic Names File (nima)
NMEA 0183 sentences (nmea)
OziExplorer (ozi)
PalmDoc Output (palmdoc)
PathAway Database for Palm/OS (pathaway)
Quovadis (quovadis)
Raymarine Waypoint File (.rwf) (raymarine)
See You flight analysis data (cup)
Sportsim track files (part of zipped .ssz files) (sportsim)
Suunto Trek Manager (STM) .sdf files (stmsdf)
Suunto Trek Manager (STM) WaypointPlus files (stmwpp)
Tab delimited fields useful for OpenOffice, Ploticus etc. (openoffice)
Textual Output (text)
TomTom Itineraries (.itn) (tomtom_itn)
TomTom POI file (.asc) (tomtom_asc)
TomTom POI file (.ov2) (tomtom)
TopoMapPro Places File (tmpro)
TrackLogs digital mapping (.trl) (dmtlog)
U.S. Census Bureau Tiger Mapping Service (tiger)
Universal csv with field structure in first line (unicsv)
Vcard Output (for iPod) (vcard)
Vito Navigator II tracks (vitosmt)
Vito SmartMap tracks (.vtt) (vitovtt)
WiFiFoFum 2.0 for PocketPC XML (wfff)
Wintec WBT-100/200 Binary File Format (wbt-bin)
Wintec WBT-100/200 GPS Download (wbt)
Wintec WBT-201/G-Rays 2 Binary File Format (wbt-tk1)
Yahoo Geocode API data (yahoo)

? Character Separated Values (xcsv)

This format can...

  • read and write waypoints @@ -360,11 +360,7 @@ distribution.

Brauniger IQ Series Barograph Download (baroiq)

This format can...

  • - read and write waypoints -

  • - read and write tracks -

  • - read and write routes + read tracks

Serial download protocol for the Brauniger IQ series of barograph recording flight instruments. This format creates a track of altitude vs time which can be merged with a GPS track @@ -602,7 +598,17 @@ If your original data contains geocaching-specific information such as difficulty and terrain, GPSBabel will automatically include that information in the waypoint descriptions in the generated drawing file. If you do not want that, specify the "nogc" option on the command line: -

gpsbabel -i gpx -f 12345.gpx -o an1,nogc -F 12345.an1

deficon option

+

gpsbabel -i gpx -f 12345.gpx -o an1,nogc -F 12345.an1

nourl option

+ Do not add URLs to description. +

+If your original waypoint data contains URLs, GPSBabel will include them as +links in the generated drawing file. This causes the waypoint symbol to have +a blue border, and it causes the waypoint text to be drawn in blue with an +underline. +

+If you do not want this behavior, specify the "nourl" option on the command +line: +

gpsbabel -i gpx -f 12345.gpx -o an1,nourl -F 12345.an1

deficon option

Symbol to use for point data.

This option allows you to specify which symbol to use for points that @@ -956,7 +962,21 @@ as follows (names of fields may depend on the language used by Fugawi):

- Name
- Comment
- Description
- Latidude
- Longitude
- Altitude (metres)
- Date (yyyymmdd/yymmdd)
- Time of day (hhmmss)

When importing tracks, use "[ignore]" instead of "Name", "Comment" and "Description".

http://www.fugawi.com/ -

Garmin 301 Custom position and heartrate (garmin301)

+

G7ToWin data files (.g7t) (g7towin)

+ This format can... +

  • + read waypoints +

  • + read tracks +

  • + read routes +

+ Like GPSBabel G7ToWin is a program which allows uploading and + downloading information from several GPS devices (Garmin, Lowrance/Eagle, Magellan). + G7ToWin has its own data format, which is an enhanced format used in Gardown. +

+ This format can read both file types, G7ToWin (.g7t) and Gardown (.gdn). +

Garmin 301 Custom position and heartrate (garmin301)

This format can...

  • read and write waypoints @@ -1005,17 +1025,32 @@ conversion code. This option specifies the default category for gdb output. It should be a number from 1 to 16.

ver option

- Version of gdb file to generate (1,2). + Version of gdb file to generate (1..3).

This option specifies the data format version for the output file. Version -2 is the default. Currently, the only other valid value for this option is -1. +2 is the default. Currently, the only other valid values for this option are +1 and 3.

via option

Drop route points that do not have an equivalent waypoint (hidden points).

This option instructs GPSBabel to drop hidden (calculated) points from routes. -

Garmin MapSource - mps (mapsource)

+

roadbook option

+ Include major turn points (with description) from calculated route. +

+ If this option is specified, GPSBabel drops all calculated route points, + with exception of points with a description (i.e. "Make U-turns until you know where you are."). + The priority of this option is higher than of the via option. + A value of 1 or y overwrites the via settings. +

Example 3.1. Using gdb option roadbook to create simple html roadbook

+ + gpsbabel -i gdb,roadbook -f sample.gdb -x nuketypes,waypoints,tracks -x transform,wpt=rte -o html -F roadbook.html + +

+ Because gdb creates internal a route AND a waypoint list, you have to drop all + waypoints and transform the route into waypoints. So you'll get a well ordered + html output. We sugess these steps for all waypoint-only formats as html. +


Garmin MapSource - mps (mapsource)

This format can...